Commit Graph

74 Commits

Author SHA1 Message Date
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
Flori 8fdbd7d84f Merge pull request #130 from polyphony-chat/refactor/change-channel-modify
Refactor/change channel modify
2023-06-22 20:05:15 +02:00
Flori Weber 99da624c15 Reflect changes to Channel::modify() in test 2023-06-22 18:55:26 +02:00
Vincent Junge d52acd9093 always use Snowflakes in args 2023-06-22 18:55:19 +02:00
Vincent Junge 709ef11f2c get channel messages 2023-06-21 14:46:45 +02:00
Vincent Junge 55b0f268e2 more consistent use of snowflakes 2023-06-20 22:03:29 +02:00
Flori 225b6e4798 Merge pull request #117 from SpecificProtagonist/gateway-event
Simplify GatewayEvent
2023-06-20 18:57:13 +02:00
kozabrada123 1f29582564 Update in tests too 2023-06-20 18:33:37 +02:00
Vincent Junge 1df01512d7 simplify GatewayEvent 2023-06-20 16:12:13 +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
Flori Weber f9000a1e90 Add block and unblock test 2023-06-19 18:46:49 +02:00
Flori Weber 4640ecf604 Add a friendship test (:3) 2023-06-19 18:11:53 +02:00
Vincent Junge f0241e0756 Make MessageSendSchema fields public 2023-06-19 14:21:27 +02:00
Vincent Junge 208eeac536 Fix various Clippy lints 2023-06-19 12:35:07 +02:00
Flori Weber 5d6aab7d36 Modift get_mutual, add get_relationships 2023-06-18 15:39:40 +02:00
Flori Weber 3bf911745f Send a friend request 2023-06-18 13:59:11 +02:00
Flori Weber 6dfb0610ec Implement test_get_mutual_relationships 2023-06-15 18:48:01 +02:00
kozabrada123 3237e7b7b7 Reformat and cargo fix 2023-06-11 14:32:37 +02:00
Flori Weber 63f09e51d8 Cargo fix 2023-06-11 13:54:54 +02:00
Flori Weber da6cffa7a3 Cargo clippy --fix 2023-06-11 13:54:08 +02:00
Flori Weber c745861592 Reformat entire project, optimize imports 2023-06-11 13:52:53 +02:00
Flori Weber f641dbb14f Reformat entire project, optimize imports 2023-06-11 13:52:31 +02:00
kozabrada123 b61bc573b7 Merge branch 'main' into perpetual/gateway-dev 2023-06-11 09:10:03 +02:00
bitfl0wer c9e6c63073 Add tests for permission modification 2023-06-10 22:26:15 +02:00
Flori Weber 7c358c338f Test singular role 2023-06-10 19:42:41 +02:00
Flori Weber 70df27162f Complete this test 2023-06-10 17:35:09 +02:00
kozabrada123 ecc6fc9424 Merge branch 'main' into perpetual/gateway-dev 2023-06-10 10:30:54 +02:00
bitfl0wer a7040647fb Add incomplete add_remove_role test 2023-06-10 00:39:04 +02:00
bitfl0wer dde43d9752 Change test due to common.rs changing 2023-06-10 00:24:08 +02:00
bitfl0wer 0887ba1019 Add role to test bundle 2023-06-10 00:23:49 +02:00
bitfl0wer affa1ed259 Update test 2023-06-09 21:35:15 +02:00
kozabrada123 10617ca85c Rebase 2023-06-09 18:14:20 +02:00
bitfl0wer 730ca5b27a Test RoleObject::create() and ::get_all() 2023-06-09 12:03:56 +02:00
bitfl0wer 66ca26db0f Add some documentation 2023-06-08 21:53:34 +02:00
kozabrada123 88d571486b Basic tests 2023-06-08 19:51:32 +02:00
bitfl0wer 315c5a00cf Refactor channels() 2023-05-29 23:59:13 +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 69993820f9 Refactor Guild create 2023-05-29 23:16:43 +02:00
bitfl0wer 072d99e879 Refactor modify() to take less boilerplate args 2023-05-29 23:11:12 +02:00
bitfl0wer ebeaf31343 Refactor delete() to take less boilerplate args 2023-05-29 23:08:52 +02:00
bitfl0wer 3e4840d7a6 Refactor get() to take less boilerplate args 2023-05-29 23:01:17 +02:00
bitfl0wer b9c3f02799 ADd test for modify_channel() 2023-05-29 18:50:09 +02:00
bitfl0wer b4cac5a65c Teardown after delete_channel 2023-05-29 18:29:08 +02:00
bitfl0wer f97f53c873 Replace guild_id with guild object 2023-05-29 16:51:41 +02:00
bitfl0wer 229a612df2 Change test delete, add test get_channels() 2023-05-29 16:51:28 +02:00