Commit Graph

624 Commits

Author SHA1 Message Date
kozabrada123 282bc06cff /* -> /// 2023-07-10 16:59:00 +02:00
Flori 8c9ccdd997
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
kozabrada123 ce359103da Use log instead of prints 2023-07-01 19:29:50 +02:00
Vincent Junge 2e9d4caee5
require password to log in 2023-06-25 22:34:05 +02:00
Vincent Junge 9ccc08b5e2
remove client side validation 2023-06-25 11:36:37 +02:00
Flori Weber 70aaa238e3
Make ReactionMeta::get() return Vec<PublicUser> 2023-06-23 12:54:08 +02:00
Flori Weber f6d6daf1d2
Fix stupid multi line comments 2023-06-23 12:18:22 +02:00
Flori fe0c09b0e9
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 0aac291a3c
Remove wrongful match statement 2023-06-22 19:54:39 +02:00
Flori f554244143
Update src/api/channels/channels.rs
Co-authored-by: SpecificProtagonist <specificprotagonist@posteo.org>
2023-06-22 19:42:07 +02:00
Flori Weber 1e0783e30e
Make Channel::modify() take &mut self 2023-06-22 18:56:16 +02:00
Vincent Junge f2709492de
always use Snowflakes in args 2023-06-22 18:55:19 +02:00
Vincent Junge 4117bcff59
ChorusResult type alias 2023-06-21 21:39:22 +02:00
Vincent Junge 8d7e49f3c2
get channel messages 2023-06-21 14:46:45 +02:00
Flori Weber e7eee4808e
Change send_request() calls to pass &mut Instance 2023-06-20 22:42:42 +02:00
Flori Weber 2233063d5f
Use Instance.client instead of creating a new one. 2023-06-20 22:42:08 +02:00
Flori Weber 27047ab909
Add reqwest::Client to chorus::Instance. 2023-06-20 22:41:31 +02:00
Flori Weber 3958f049ea
Change to single-line docstring 2023-06-20 22:36:39 +02:00
Flori Weber 0a523d54c1
Multiline docstring to single line docstring 2023-06-20 22:30:42 +02:00
Flori Weber 1fc38b25bf
Merge branch 'main' into refactor/reuse-reqwest-client 2023-06-20 22:21:08 +02:00
Flori Weber 915c9be4ad
Change docstring from multi- to singleline 2023-06-20 22:20:06 +02:00
Flori 6e50292f71
Merge pull request #122 from SpecificProtagonist/winter
More consistent use of snowflakes
2023-06-20 22:16:54 +02:00
Vincent Junge 9429bd7772
more consistent use of snowflakes 2023-06-20 22:03:29 +02:00
Flori 9725b165dd
Merge pull request #121 from polyphony-chat/fix/cannot-connect-to-discord
Remove unnecessary things
2023-06-20 21:54:53 +02:00
Flori 304cb6076a
Merge pull request #114 from SpecificProtagonist/snowflake
Simplify Snowflake
2023-06-20 18:57:25 +02:00
Flori dcacfacda9
Merge pull request #117 from SpecificProtagonist/gateway-event
Simplify GatewayEvent
2023-06-20 18:57:13 +02:00
kozabrada123 b8d7030ab1 Change Option<ChorusLibError> to Result<(), ChorusLibError> 2023-06-20 18:26:30 +02:00
Vincent Junge 04c3ee56e9
simplify GatewayEvent 2023-06-20 16:12:13 +02:00
Vincent Junge f614e93892
UrlBundle remove getters 2023-06-20 12:29:52 +02:00
Vincent Junge 29fcdfe641
simplyfy Snowflake 2023-06-20 12:21:22 +02:00
Flori Weber be7b9616c2
Remove unnecessary things 2023-06-20 00:35:46 +02:00
Flori Weber 603c8c8150
apply clippy suggestions 2023-06-19 19:01:18 +02:00
Flori Weber 17223d338a
change post to delete 2023-06-19 18:12:09 +02:00
Flori Weber 06b4f5fb65
Add Eq, PartialEq derives 2023-06-19 18:12:01 +02:00
Vincent Junge de5fe8aebf
Fix clippy::await_holding_refcell_ref false positives 2023-06-19 16:46:58 +02:00
Flori Weber b8e8a1c23a
Fix build failing 2023-06-19 16:11:53 +02:00
Vincent Junge cadf14ba6a
Make MessageSendSchema fields public 2023-06-19 14:21:27 +02:00
Vincent Junge 37de1d7b06
Fix various Clippy lints 2023-06-19 12:35:07 +02:00
Flori Weber a05241dd8e
Add remove_relationship 2023-06-18 23:10:29 +02:00
Flori Weber 6d8e0aaa39
Remove unneccessary imports 2023-06-18 23:04:25 +02:00
Flori Weber 636cb4c751
Add modify_user_relationship 2023-06-18 23:02:49 +02:00
Flori Weber 6878fd0380
Fix errors not displayed, add InvalidArgumentsErr 2023-06-18 23:01:38 +02:00
Flori Weber 4829845512
Move FriendRequestSchema to schemas 2023-06-18 19:05:09 +02:00
Flori Weber 191dc34933
Create relationship schemes 2023-06-18 19:04:55 +02:00
Flori Weber 0460a67bdd
Change returns, add documentation 2023-06-18 15:39:52 +02:00
Flori Weber fc6b431ad8
Start implementing get_relationship 2023-06-18 14:00:12 +02:00
Flori Weber cd303b0fef
Add FriendRequestSendSchema 2023-06-15 19:01:01 +02:00
Flori Weber e971ed2b49
Implement send_friend_request 2023-06-15 19:00:47 +02:00
Flori Weber 8378c5ccb6
Add get_mutual_relationships 2023-06-14 22:54:14 +02:00
Flori Weber 6312bd3572
Change belongs_to to be borrowed non-mutably 2023-06-14 22:53:56 +02:00
Flori Weber b56b5f5f12
Format relationships.rs 2023-06-14 22:14:56 +02:00
Flori Weber 2a8a8d75d3
Add relationships.rs 2023-06-14 22:14:48 +02:00
Flori Weber 870d5606a0
Update link reference 2023-06-13 15:23:39 +02:00
Flori Weber dfec24b8b8
Update relationship.rs types 2023-06-13 15:23:06 +02:00
Flori Weber bcc4069cea
Create relationships.rs 2023-06-13 14:04:58 +02:00
Flori Weber c6dcfff6a8
Create relationships.rs 2023-06-13 14:04:39 +02:00
bitfl0wer 8de2d3b5c3
run cargo fix 2023-06-12 18:59:06 +02:00
bitfl0wer 550d6d9265
run cargo fix 2023-06-12 18:58:53 +02:00
bitfl0wer 1aad39ded1
Remove unneccessary variable 2023-06-12 18:55:27 +02:00
bitfl0wer 98a043ab30
Refactor limited requester
The requester does not need to be instantiated anymore, which makes things easier to read imo.
2023-06-12 18:51:54 +02:00
Flori Weber 1910649ac4
Refactor users.rs to use api::common 2023-06-11 21:40:03 +02:00
Flori Weber 43e62359ae
Refactor roles.rs to use api::common 2023-06-11 20:04:40 +02:00
Flori Weber c03c3357fa
Refactor member.rs to use api::common 2023-06-11 19:30:15 +02:00
Flori Weber 3f8724535e
Refactor guilds.rs to use api:common 2023-06-11 19:26:34 +02:00
Flori Weber f6da3dcacf
Use handle_request_as_option instead 2023-06-11 19:22:28 +02:00
Flori Weber 3a8b6c8629
Introduce handle_request_as_option 2023-06-11 19:22:10 +02:00
Flori Weber fac9937bdd
Refactor reactions to use api::options 2023-06-11 19:13:38 +02:00
Flori Weber c479db36fb
Refactor permissions.rs to use api::common 2023-06-11 17:56:29 +02:00
Flori Weber 90ad75ae30
Remove import 2023-06-11 17:51:26 +02:00
Flori Weber ce004b3863
Refactor Message::send() 2023-06-11 17:49:42 +02:00
Flori Weber 583031e64f
Make some fields Option enum 2023-06-11 17:49:30 +02:00
Flori Weber 59d512cdce
Refactor to use api common, return Message instead 2023-06-11 17:40:44 +02:00
Flori Weber bf005c44a4
Refactor channels.rs to use api::common 2023-06-11 17:36:04 +02:00
Flori Weber 5d039c3e9b
Add argument to specify which LimitType to use 2023-06-11 17:35:47 +02:00
Flori Weber 9449c4cd4d
Move common request code into common.rs 2023-06-11 17:21:09 +02:00
Flori Weber ebe8a054e0
Merge branch 'main' into feature/permissions-and-roles 2023-06-11 15:34:43 +02:00
Flori Weber 3f7bf0c912
create common.rs 2023-06-11 15:34:05 +02:00
kozabrada123 dc5e91a784 Reformat and cargo fix 2023-06-11 14:32:37 +02:00
Flori Weber 8b8ea03513
Cargo fix 2023-06-11 13:55:00 +02:00
Flori Weber 41135d037f
Cargo fix 2023-06-11 13:54:54 +02:00
Flori Weber f585e0ddae
Reformat entire project, optimize imports 2023-06-11 13:52:53 +02:00
Flori Weber f4e0d520b1
Reformat entire project, optimize imports 2023-06-11 13:52:31 +02:00
kozabrada123 f5bbd3d737 Merge branch 'main' into perpetual/gateway-dev 2023-06-11 09:10:03 +02:00
bitfl0wer 6952f9977f
Implement delete_permission 2023-06-10 22:16:53 +02:00
bitfl0wer 87e70181fb
impl Channel::edit_permissions() 2023-06-10 22:09:53 +02:00
bitfl0wer 48a063838b
Create permissions.rs 2023-06-10 21:51:45 +02:00
Flori Weber e5aff12f94
"Normalize" RolePositionUpdateSchema 2023-06-10 19:35:57 +02:00
Flori Weber 5b66464ce9
Better error handling in get methods. 2023-06-10 18:50:49 +02:00
Flori Weber a9b02bad78
Implement RoleObject::get() 2023-06-10 18:48:37 +02:00
Flori Weber 9a6ac33a40
Add RoleObject::update() 2023-06-10 18:42:37 +02:00
kozabrada123 94ec90b924 Implement display for UserStatus 2023-06-10 16:56:50 +02:00
kozabrada123 330a4347d3 turns out UpdatePresence and PresenceUpdate are different events 2023-06-10 16:32:42 +02:00
kozabrada123 57d2d93420 Change observer update ref to &mut from & 2023-06-10 15:37:02 +02:00
Flori Weber d5e38d954f
Implement GuildMember::get() 2023-06-10 15:16:45 +02:00
kozabrada123 a148cf576e Refactor, better deserialization error handling 2023-06-10 12:43:07 +02:00
kozabrada123 0b06f914e3 Merge branch 'main' into perpetual/gateway-dev 2023-06-10 10:30:54 +02:00
bitfl0wer a18eab1884
Change UserMeta: User instead of Option<User>
I do not know why I have made it optional in the first place. hm
2023-06-10 00:35:51 +02:00
bitfl0wer 30db9e9553
implement GuildMember::remove_role() 2023-06-10 00:10:12 +02:00
bitfl0wer 3d98b45413
Implement GuildMember::add_role() 2023-06-10 00:03:31 +02:00
bitfl0wer daf30ddde6
create member.rs 2023-06-09 23:41:40 +02:00