Commit Graph

1351 Commits

Author SHA1 Message Date
bitfl0wer 9246fd9504 Add `GatewayHandle` to `UserMeta` 2023-07-22 14:38:55 +02:00
SpecificProtagonist 9ebe72a7dc derive Updateable (#167) 2023-07-22 11:20:31 +02:00
Flori ccf44a5375 Auto updating structs (#163)
* Gateway fields don't need to be pub

* Add store to Gateway

* Add UpdateMessage trait

* Proof of concept: impl UpdateMessage for Channel

* Start working on auto updating structs

* Send entity updates over watch channel

* Add id to UpdateMessage

* Create trait Updateable

* Add documentation

* add gateway test

* Complete test

* Impl UpdateMessage::update() for ChannelUpdate

* Impl UpdateMessage::update() for ChannelUpdate
Co-authored by: SpecificProtagonist <specificprotagonist@posteo.org>

* make channel::modify no longer mutate Channel

* change modify call

* remove unused imports

* Allow dead code with TODO to remove it

* fix channel::modify test

* Update src/gateway.rs

Co-authored-by: SpecificProtagonist <vincentjunge@posteo.net>

---------

Co-authored-by: SpecificProtagonist <vincentjunge@posteo.net>
2023-07-21 15:35:31 +02:00
kozabrada123 44d9655e8e Merge stuff 2023-07-21 14:10:50 +02:00
SpecificProtagonist 776efce4dc Fix gateway heartbeat blocking (#162)
fix gateway heartbeat blocking
2023-07-21 13:59:40 +02:00
Flori 85fb24cd8c Fix: message file attachment duplication (#159)
* make send() take ownership of MessageSendSchema

* Remove message file attachment duplication

* Remove superfluous docstrings
2023-07-17 23:26:25 +02:00
Flori df08bc33ac Bump crate versions (#158) 2023-07-17 20:06:57 +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 378a05c2d7 Update code-ql action to v2 2023-07-17 19:35:16 +02:00
Flori 3928f52d83 Delete clippy.yml 2023-07-17 12:36:45 +02:00
Flori 8a09512e3d Create rust-clippy.yml 2023-07-17 12:36:33 +02:00
Flori 6f3bd04963 Enable saving and loading LimitsConfiguration (#152)
Impl Serialize, Deserialize for LimitsConfiguration and children
2023-07-14 17:38:54 +02:00
kozabrada123 1163b32460 Revert actions build back to debug (#151)
Cargo build --release is faster for builds, but test uses debug built libraries, so it rebuilds them
2023-07-14 12:12:39 +02:00
kozabrada123 0cd1f81421 Faster actions hopefully (#150) 2023-07-14 11:58:12 +02:00
SpecificProtagonist db0b1131ed Deduplicate gateway dispatch event handling (#148)
deduplicate gateway dispatch event handling
2023-07-11 20:11:13 +02:00
kozabrada123 a0d2fc8213 Add some docs 2023-07-11 19:54:04 +02:00
kozabrada123 3b35f03993 Merge branch 'main' into fix/doc-improvements 2023-07-11 19:24:37 +02:00
Zert3x 0d6d705e46 Async Observer Trait (#147) 2023-07-11 19:20:27 +02:00
kozabrada123 18ac7b5708 Rustdoc warnings + misc changes 2023-07-10 18:06:45 +02:00
kozabrada123 322894e4e9 UrlBundle slightly better docs 2023-07-10 17:22:31 +02:00
kozabrada123 192f12d892 /* -> /// 2023-07-10 16:59:00 +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
kozabrada123 54d3eeac95 Merge pull request #143 from polyphony-chat/feature/use-log
Use log instead of prints
2023-07-01 17:44:44 +00:00
kozabrada123 3f6d0e2d9d Use log instead of prints 2023-07-01 19:29:50 +02:00
Flori 43601019e8 Merge pull request #137 from SpecificProtagonist/server-side-validation
Remove some client-side validation
2023-06-27 00:05:52 +02:00
Vincent Junge 94a051631f require password to log in 2023-06-25 22:34:05 +02:00
Vincent Junge 8b0f41fad3 remove client side validation 2023-06-25 11:36:37 +02:00
kozabrada123 ad4c96217c Merge pull request #136 from SpecificProtagonist/tokio-features
Correct tokio features
2023-06-24 08:23:07 +00:00
Vincent Junge c0d484efdc fixed tokio features 2023-06-24 08:52:45 +02:00
Flori d474ea1da8 Merge pull request #134 from polyphony-chat/bug/reactionsget-returns-generic-successfailure
Make ReactionMeta::get() return a Vec<PublicUser>
2023-06-23 13:34:05 +02:00
Flori Weber ecf54111a6 cargo fix 2023-06-23 12:54:15 +02:00
Flori Weber c25795ab4d Make ReactionMeta::get() return Vec<PublicUser> 2023-06-23 12:54:08 +02:00
Flori Weber 6c9df9508e Fix stupid multi line comments 2023-06-23 12:18:22 +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 c00cc215fe Remove wrongful match statement 2023-06-22 19:54:39 +02:00
Flori f647f14d82 Merge pull request #128 from SpecificProtagonist/deep_winter
Always use Snowflakes in args
2023-06-22 19:44:15 +02:00
Flori 6c0faa29f3 Update src/api/channels/channels.rs
Co-authored-by: SpecificProtagonist <specificprotagonist@posteo.org>
2023-06-22 19:42:07 +02:00
Flori Weber 7fb37ff204 Make Channel::modify() take &mut self 2023-06-22 18:56:16 +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
Flori d21dc931f0 Merge pull request #125 from SpecificProtagonist/result
ChorusResult type alias
2023-06-21 21:45:39 +02:00
Vincent Junge f98180cd03 ChorusResult type alias 2023-06-21 21:39:22 +02:00
Flori 067d728874 Merge pull request #126 from SpecificProtagonist/get-channel-messages
Get channel messages
2023-06-21 21:19:37 +02:00
Vincent Junge 709ef11f2c get channel messages 2023-06-21 14:46:45 +02:00
Flori 82573a58b1 Merge pull request #123 from polyphony-chat/refactor/reuse-reqwest-client
Refactor/reuse reqwest client
2023-06-21 09:50:25 +02:00
Flori Weber 62f6bfa363 Change send_request() calls to pass &mut Instance 2023-06-20 22:42:42 +02:00
Flori Weber 6650bcf1df Use Instance.client instead of creating a new one. 2023-06-20 22:42:08 +02:00
Flori Weber 6542a7a362 Add reqwest::Client to chorus::Instance. 2023-06-20 22:41:31 +02:00
Flori Weber 6eb3cf65d1 Change to single-line docstring 2023-06-20 22:36:39 +02:00
Flori Weber 20f39a409d Multiline docstring to single line docstring 2023-06-20 22:30:42 +02:00