Commit Graph

29 Commits

Author SHA1 Message Date
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