Commit Graph

38 Commits

Author SHA1 Message Date
kozabrada123 3e22b5c0ed
🎉 Release 0.16.0
* add WebSocketEvent macro derive, bump chorus-macros to 0.3.0 (#490)

* feat: add WebSocketEvent derive, bump to 0.2.1

* change license, version of macros

* Use WebSocketEvent derive instead of impl WebSocketEvent for .. (#491)

use derive macro instead of manual impl blocks

* Move Shared<T> to types/mod.rs, bump some dependencies (#492)

* deps: bump rustls to 0.21.11

This is done to fix CVE-2024-32650, which practically shouldn't affect
us but it's still better not to use vulnerable dependencies.

* deps: bump h2 to 0.3.26

This is done to fix another vulnerability, which should also not affect
us (non-critical, in h2 servers)

* fix: move Shared<T> to types/mod.rs

* Reuse gateway backends, don't duplicate them for voice gateway (#493)

* Refactor / fix login and register (#495)

Change login and register to only use one ChorusUser object, change the
api of related methods which were also somewhat ugly

* Add the repository field to Cargo.toml

* Ci improvements (#498)

* bump wasm-bindgen version to 0.2.92

* change wasm-gecko to using ubuntu-latest, since geckodriver is not supported on macos-latest

* check some common non-default feature configurations

* add experimental semver checks

* Update poem dependency

* Convert timestamp fields to DateTime's

* Feature lock different types for UserSettings::status

* Make config register_configuration use Rights bitflag object

* Update tests to use DateTime's for timestamps

* Fix tests

* Allow joined_at to default if field is not in responses.

* Allow last_pin_timestamp to default if field is not in responses.

* Remove serde(with) for message timestamps

* Fix some iso timestamps being strings, not DateTime<Utc> (#499)

* fix: some iso timestamps being strings

* fix: register uses dates, not datetimes

* Add sqlx::FromRow derive to GuildMember

* remove dep: prefix in backend feature list

* Implement sqlx Encode, Decode, Type for Rights bitflag object.

* Use Snowflake in Claims

* Use ChannelType enum on ChannelModifySchema

* Feature lock Shared, so backend feature gets a facade type

* Remove erroneous serde with attributes

* Add From<Vec<GuildFeatures>> impl for GuildFeaturesList

* Add feature sqlx locks for user, roles on GuildMember

* Use distinct type for explicit_content_filter

* Remove unused imports

* Revert c4452132

* Remove final usages of erroneous serde impl

* Fix errors in documentation tests

* update dev-dependencies

* actually fix linux tests

* clear warnings

* Update Cargo.lock

* Expand documentation to explain facade type

* Fix oversight for premium_since

* Backend related updates (#501)

(by Quat3rnion)

Some updates relating to usage with Symfonia:
* Using distinct types instead of primitives on some objects
* Add sqlx derives and implementations
* Make a facade type for Shared to be used in non-client contexts

* Distinguish InviteType and InviteTargetType

* Add sqlx Type, Encode, Decode impl for InviteFlags bitflag object.

* Use distinct type `DefaultReaction`

* Update fields for backend/sqlx compatibility.

* Update derive for backend/sqlx compatibility.

* Write custom serialize/deserialize impl's for InviteFlags

* Clear warnings

* Add InviteFlags::VIEWED

* Remove double bound for E

* Use distinct types in `InviteGuild` object.

* Implement `From<Guild> for InviteGuild`

* Add `GetInvitesSchema`

* Add forgotten import and pub use.

* Fix compile error

* Update docs aesthetics

Co-authored-by: kozabrada123 <59031733+kozabrada123@users.noreply.github.com>

* Add type locks

* Fix inverted type wrapping

* Update Cargo.lock

* Add SqlxBitFlags derive macro

* Utilize new macros and use distinct Flag types

* Add distinct MessageType enum

* Fix error in macro

* Make UserFlags deserialize from string

* Add partial emoji and custom reaction types, refine SQLx mapping

* Use chorus_macros from path, since it's there anyway

* Fix test

* Add forgotten feature locks

* Remove unused imports, feature locks in macro

* forgot a file :(

* Feature lock the macro

* Dirty hack

* Fix test

I feel silly.

* Fix compilation for real, no dirty hack

* Maybe fix tests, make UserFlags able to be deserialized from String or u64

* Add new SerdeBitFlags derive macro, to help reduce repetitive code

* u8 -> u64

* Fix deserialization error w/ guild features list

* chorus macros 0.4.0

* always update to latest release of macros

* Update and add some types in support of the backend (#507)

* Implement gateway options, zlib-stream compression (#508)

* feat: add GatewayOptions

* feat: implement zlib-stream compression

This also changes how gateway messages work.
Now each gateway backend converts its message into an
intermediary RawGatewayMessage, from which we inflate
and parse GatewayMessages.

Thanks to ByteAlex and their zlib-stream-rs crate, which
helped me understand how to parse a compressed websocket stream

* Backend/guilds (#509)

* Fix SQL encode/decode for GuildFeatures

* Use distinct PermissionFlags type

* Add Emoji schema types, modify GuildBan with feature lock

* Add Schemas for pruning guild members

* Add schemas for interfacing with stickers backend routes

* Add schemas for interfacing with vanity-url backend routes

* Add schema for interfacing with guilds/id/welcome-screen route

* Make all Option<Vec> types Vec types with #[serde(default)]

* Add various types to support guilds/* api routes

* Add missing enums and structs for searching messages

* Use proper distinct types

* Add EmbedType enum

* Use distinct PermissionFlags type

* Changes supporting backend for VoiceState

* Changes supporting backend for AuditLog's

* Add custom deserializer for PermissionOverwriteType (#512)

* Add custom deserializer for PermissionOverwriteType

* Miscellaneous fixes (#514)

- fix `PATCH /users/@me` - It incorrectly returned a required password error, even if the current password was set
- fix `GET /users/@me/guilds` - It incorrectly sent body parameters instead of query ones
- don't log debug! for every successful ratelimited request - use trace! so it's less spamy
- update the max expected compression ratio (several times) from 20 to 200. let's hope that will be enough
- fix deserialization errors relating to guild folders in user settings
- fix a panic in `SqlxBitFlags` if there are extra flags. It now truncates them
- update `chorus_macros` to 0.4.1 (due to the above fix)
- log (trace!) event data if we fail to parse it or it's unrecognised, for debugging purposes
- fix a deserialization error in the `MessageACK` event
- fix `public_flags` in user objects not being `PublicFlags` bitflags

* No openssl (#522)

* Remove openssl from some packages' deps

* Add shorthand wasm build script

* Eliminate openssl dependency from crate

* Build RootCertStore from webpki roots instead of native roots

* Expand wasm documentation

* Revert reqwest

* Lock reqwest at 0.11.23

* Lock reqwest at 0.11.26, latest possible version

* Add wasm test script

* Replace `Observer` and `GatewayEvent` with `pubserve` crate

* Fix voice, voice_udp features

* Add one BILLION derives

* Provide alternative implementations for PartialEq for some types when sqlx feature is enabled

* Provide alternative implementations for PartialEq for some types when sqlx feature is enabled

* Fix: Wrong function name

* Fix: Turn unconditional import of sqlx::types::Json into conditional one

* Fix: Compile error with no default features

* Update CONTRIBUTING.md

* Use cargo nextest

* Use cargo nextest

* Fix/Correct UnavailableGuild object

* Fix testcase that relied on false behavior implemented by older spacebar servers

* Increase limit integer size to match spacebars' possibilities

* Cargo nextest on wasm, Parallelize "Check common non-default feat. cfg."

* forgor installing nextest

* Revert: nextest on wasm

* Bump browser_version according to https://www.useragents.me/#most-common-desktop-useragents

* Fix voice_simple example

* Update documentation in gateway_observers example

* Readd Observer trait as reexport

* remove cargo lock from example

* Fix #525 (pr #532)

* change theme_colors from Vec<u32> to (u32, u32)

* Custom ThemeColors type with sqlx::Encode and sqlx::Decode impls

* impl sqlx::Type for ThemeColors

* More accurate "GatewayHello::default()"

* Manually implement std::default::Default for GatewayHeartbeat and GatewayHeartbeatAck

* bump versions of packages to latest compatible versions

* Update MSRV (#540)

* Update msrv

* sqlx related improvements (#542)

* Bump sqlx to 0.8.0

* Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any

* Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any

* Modify chorus_macros::SqlxBitflagDerive to use sqlx::Any over sqlx::MySql (broken!)

* Fix: `cannot infer type for type parameter `DB` declared on the trait...`

* Change remaining impls of sqlx traits for MySql to sqlx::Any

* Alter chorus_macros to correctly derive SqlxBitFlag for sqlx::Any

* rustc/clippy>=v1.80.0: Do not warn when encountering cfg(tarpaulin_include)

* Port compare_* methods to sqlx v0.8.0

* CI/CD: add cargo-doc job (#544)

* CI/CD: add cargo-doc job

* fix: make it rustdoc, totally not clippy

* Initial support for PostgreSQL (#548)

* Change sqlx::Any to sqlx::Postgres

* Change sqlx::Any to sqlx::Postgres

* Remove JSONified overrides when sqlx feature is enabled, where it makes sense

* Add num-bigint dep

* Remove generic impl for From<T> for Snowflake
For some reason, this trait bound conflicts with another trait bound from the sqlx-pg-uint crate, even though I personally don't get why.

* Remove num_bigint, adsd sqlx-pg-uint

* swap u64 for PgU64 in some files

* use v0.3.0 of sqlx-pg-uint

* Lots of sqlx-postgres type changes

* Lots of sqlx-postgres type changes

* gwah

* Change repr(i8) to repr(i16) in enums when sqlx feature is enabled, fix sqlx incompatibilities

* impl sqlx::postgres::PgHasArrayType for Snowflake

* Try: derive Type for FriendSourceFlags, GuildFolder

* Try: Derive FromRow, Type for DefaultReaction

* Try: Derive Type for CustomStatus

* Try: Derive Type, FromRow for Tag

* Replace conditional compiling of uNN/PgUNN with conditional compiled type alias

* Fix: Conditional compiling errors and warnings

* Bump: wasm-bindgen* crate versions

* Bump sqlx-pg-uint

* Uncomment and update decode_token()

* Snowflake: PgU64 as base for sqlx (#551)

* Bump sqlx-pg-uint, sqlx

* Use PgU64 as base for implementations of sqlx traits for Snowflake

* sqlx_bitflag_derive: Use PgU64 as translation base (#552)

* sqlx_bitflag_derive: Use PgU64 as translation base

* Bump version of chorus-macros

* Prefer `&str` over `String` when possible (#553)

Prefer &str over String where possible.

* Tungstenite: Match scheme for "ws" or "wss" (#554)

Match scheme for "ws" or "wss" and choose whether to connect with TLS connector for tungstenite

* Add missing `impl From<Snowflake> for u64`, closes `From<Snowflake> for u64` missing #550

* Update README.md

* Bump package versions

* move up sending identify

* Make instance GatewayOptions configurable for library consumers (#555)

* Make instance GatewayOptions configurable for library consumers

* Update example in README

* Revert d846ce9948

* 0.16.0: fix lints (#558)

* chore: fix doc lints

* fix: use different chrono function due to deprecation

* chore: format

* Bump version to v0.16.0

---------

Co-authored-by: Gábor Szabó <gabor@szabgab.com>
Co-authored-by: Flori <39242991+bitfl0wer@users.noreply.github.com>
Co-authored-by: Quat3rnion <quat3rnion@proton.me>
Co-authored-by: Quat3rnion <81202811+Quat3rnion@users.noreply.github.com>
Co-authored-by: bitfl0wer <florian@pro-weber.com>
2024-08-28 20:11:52 +02:00
Flori 64feb91680 License change (#477) 2024-01-31 23:59:42 +01:00
Dirk Stolle c5bfac66e5 Fix a few typos (#471) 2024-01-31 22:27:53 +01:00
bitfl0wer b8ba92cf07 Include license header everywhere 2024-01-30 17:19:34 +01:00
bitfl0wer b521928f81 Make IntoShared trait with blanket implementation 2024-01-22 14:56:23 +01:00
bitfl0wer c4bea069b7 Fix errors by moving into_shared out of Composite 2024-01-22 14:50:33 +01:00
bitfl0wer 400d4c74cf Rename to_shared to into_shared 2024-01-21 17:10:24 +01:00
bitfl0wer 39b1f1fa72 Replace use of Arc<RwLock<T>> with Shared<T> 2024-01-21 17:07:19 +01:00
bitfl0wer 1c4721a70f Refactor instance creation 2023-12-15 00:10:33 +01:00
bitfl0wer f5774ae047 Remove "limited" parameter 2023-12-03 21:34:44 +01:00
bitfl0wer a4d5ebb689 Resolve merge conflicts 2023-11-19 19:12:29 +01:00
bitfl0wer 862a846055 Rename `get_handle` to `spawn` 2023-11-18 19:07:56 +01:00
bitfl0wer 5bbf1cef1f Add prefix "Default" To Gateway, -Handler and HeartbeatHandler 2023-11-15 20:58:10 +01:00
bitfl0wer 5af6d1ce4b Refactor Gateway module to implement traits and
improve code structure
2023-11-15 18:44:19 +01:00
bitfl0wer e17fcd9e0f Make login only take owned values 2023-09-01 13:01:50 +02:00
bitfl0wer a8bcb58493 Make auth functions take owned values, similar to the rest of the API 2023-09-01 12:12:07 +02:00
kozabrada123 3d8d6b6f3b Make GatewayHandle Clone 2023-08-29 14:24:32 +02:00
bitfl0wer 17fe4f004f Make ChorusUser `Clone` 2023-08-29 00:05:16 +02:00
bitfl0wer d73c1963fc Start refactoring ChorusRequest to ChorusRequest::new() 2023-08-25 00:02:26 +02:00
bitfl0wer fb7e33c0ec Change `UserMeta` to `ChorusUser` 2023-08-24 21:06:28 +02:00
bitfl0wer 9ac5925bf9 Make channel_type in ChannelCreateSchema of type enum "ChannelType" 2023-08-22 17:55:29 +02:00
fowb 29d4ef23a2 Change T: Updateable to Arc<RwLock<T>> 2023-08-12 22:40:40 +02:00
bitfl0wer 25704f6dda Make user::shell async due to gateway add 2023-07-22 14:39:36 +02:00
Flori 1fdbe6cc00 Join/Leave Guilds, (Group) DMs and minor improvements (#157)
## Summary:

**Added:**
- Schemas `PrivateChannelCreateSchema` `ChannelInviteCreateSchema`, `AddChannelRecipientSchema` recursively (including schemas which were needed to create these schemas)
- Methods `create_private_channel`, `leave_guild`, `accept_invite`, `create_user_invite`, `create_guild_invite`, `add_channel_recipient`, `remove_channel_recipient`
- Integration tests for the functionality covered by implementing #45
- Documentation in some places where I noticed it would be useful to have some
- `create_user` method in `/src/tests`: Cuts down on test boilerplate needed to create an addition test user

**Changed:**
- `.gitignore`
  - Added `.DS_store` files to gitignore (some weird macos files), removed Cargo.lock, as Cargo.lock should be included for libraries
- Added a lot of default trait derives like Clone, Copy, PartialEq, Eq, Ord, PartialOrd to structs and enums where I saw them missing
- Added missing `teardown()` calls to the integration tests
- Renamed integration test files in `/src/tests` dir to all be plural: `channel.rs` -> `channels.rs`
- Made more fields on `User` type `Option<>`
- All instances in `/src/tests` where a second test user was created using a RegistrationSchema and the register_user method were replaced with the new `create_user` method
- README.md: Marked roadmap fields covered by #45 as implemented
- Changed visibility of `/src/tests/common/mod.rs` methods from `pub` to `pub(crate)`. In hindsight, this was probably not required, haha

**Removed:**
- Unneeded import in`src/types/config/types/guild_configuration.rs`


## Commit log:

* Add .DS_store, remove Cargo.lock

* Create PrivateChannelCreateSchema

* pub use users

* add channels.rs

* create channels.rs

* Add Deserialize/Serialize derives

* Implement create_private_channel

* Add create_dm() test

* Make optional fields on `User` `Option<>`

* Check boxes for implemented features

* Create users/guilds.rs

* Remove unneeded import

* Add UserMeta::leave_guild()

* Create api/invites/mod.rs

* Add debug print to send_request

* Rename tests files

* Create invites.rs

* create invite.rs

* Add documentation

* Implement accept_invite

* Sort fields on Channel alphabetically

* Add invite mod

* Add forgotten teardown() at test end

* change visiblities, add create_user()

* Implement `create_user_invite()`

* start working on invite tests

* Add allow flags

* Fix bad url

* Create CreateChannelInviteSchema and friends

* remove non-implemented test code

* add body to requests

* Add Clone to UserMeta

* More comprehensive error message when running into a deserialization error

* Add arguments documentation to accept_invite

* Add Eq derive to GuildFeaturesList

* Add Eq derive to Emoji

* Add Eq derive to GuildBan

* Add create_accept_invite() test

* Add Default derive to ChannelCreateSchema

* Change create_guild_invite to return GuildInvite

* Dates as chrono::Date(Utc); sort alphabetically

* Add default derives wherever possible

* Implement add_- and remove_channel_recipient

* Create AddChannelRecipientSchema

* replace otheruser regs with bundle.creeate_user()

* Add (disabled) test remove_add_person_from_to_dm()
2023-07-17 19:36:28 +02:00
Flori 69b7c2445c Ratelimiter overhaul (#144)
* Rename limits and limit to have better names

* Remove empty lines

* Remove handle_request (moved to requestlimiter)

* Start working on new ratelimiter

* Make limits Option, add "limited?" to constructor

* Add missing logic to send_request

* Rename Limits

* Create Ratelimits and Limit Struct

* Define Limit

* Import Ratelimits

* Define get_rate_limits

* Remove unused import

* + check_rate_limits & limits_config_to_ratelimits

* Remove Absolute Limits
These limits are not meant to be tracked anyways.

* add ratelimits is_exhausted

* Add error handling and send request checking

* change limits to option ratelimits

* Add strum

* Change Ratelimits to Hashmap

* Remove ratelimits in favor of hashmap

* Change code from struct to hashmap

* start working on update rate limits

* Remove wrong import

* Rename ChorusLibError to ChorusError

* Documented the chorus errors

* Made error documentation docstring

* Make ReceivedErrorCodeError have error string

* Remove unneeded import

* Match changes in errors.rs

* Improve update_rate_limits and can_send_request

* add ratelimits.to_hash_map()

* use instances' client instead of new client

* add LimitsConfiguration to instance

* improve update_limits, change a method name

* Fix un-updated errors

* Get LimitConfiguration in a sane way

* Move common.rs into ratelimiter::ChorusRequest

* Delete common.rs

* Make instance.rs use overhauled errors

* Refactor to use new Rate limiting implementation

* Refactor to use new Rate limiting implementation

* Refactor to use new Rate limiting implementation

* Refactor to use new Rate limiting implementation

* Refactor to use new Rate limiting implementation

* Refactor to use new Rate limiting implementation

* update ratelimiter implementation across all files

* Fix remaining errors post-refactor

* Changed Enum case to be correct

* Use result

* Re-add missing body to request

* Remove unneeded late initalization

* Change visibility from pub to pub(crate)
I feel like these core methods don't need to be exposed as public API.

* Remove unnecessary import

* Fix clippy warnings

* Add docstring

* Change Error names across all files

* Update Cargo.toml

Strum is not needed

* Update ratelimits.rs

* Update ratelimits.rs

* Bug/discord instance info unavailable (#146)

* Change text to be more ambigous

* Use default Configuration instead of erroring out

* Emit warning log if instance config cant be gotten

* Remove import

* Update src/instance.rs

Co-authored-by: SpecificProtagonist <specificprotagonist@posteo.org>

* Add missing closing bracket

* Put limits and limits_configuration as one struct

* Derive Hash

* remove import

* rename limits and limits_configuration

* Save clone call

* Change LimitsConfiguration to RateLimits
`LimitsConfiguration` is in no way related to whether the instance has API rate limits enabled or not. Therefore, it has been replaced with what it should have been all along.

* Add ensure_limit_in_map(), add `window` to `Limit`

* Remove unneeded var

* Remove import

* Clean up unneeded things
Dead code warnings have been supressed, but flagged as FIXME so they don't get forgotten. Anyone using tools like TODO Tree in VSCode can still see that they are there, however, they will not be shown as warnings anymore

* Remove nested submodule `limit`

* Add doc comments

* Add more doc comments

* Add some log messages to some methods

---------

Co-authored-by: SpecificProtagonist <specificprotagonist@posteo.org>
2023-07-09 18:38:02 +02:00
Vincent Junge 8b0f41fad3 remove client side validation 2023-06-25 11:36:37 +02:00
Flori Weber ecf54111a6 cargo fix 2023-06-23 12:54:15 +02:00
Vincent Junge d52acd9093 always use Snowflakes in args 2023-06-22 18:55:19 +02:00
Vincent Junge 9c7031abde UrlBundle remove getters 2023-06-20 12:29:52 +02:00
Flori Weber ec3a531f48 apply clippy suggestions 2023-06-19 19:01:18 +02:00
Vincent Junge 208eeac536 Fix various Clippy lints 2023-06-19 12:35:07 +02:00
bitfl0wer 0887ba1019 Add role to test bundle 2023-06-10 00:23:49 +02:00
bitfl0wer 671c5d6191 Refactor create 2023-05-29 23:57:23 +02:00
bitfl0wer 03e5a83d84 Refactor delete() 2023-05-29 23:51:12 +02:00
bitfl0wer b501aca5b2 Refactor create() and get() 2023-05-29 23:46:43 +02:00
bitfl0wer f97f53c873 Replace guild_id with guild object 2023-05-29 16:51:41 +02:00
bitfl0wer 915ab010ed Remove newline at beginning of file 2023-05-27 22:47:14 +02:00
bitfl0wer 1b17904403 Move common code into common::<> 2023-05-27 22:12:07 +02:00