Commit Graph

142 Commits

Author SHA1 Message Date
bitfl0wer a48850a241
Clean up test 2023-08-15 20:20:58 +02:00
bitfl0wer 38e661075f
Try calling new method to see if it panics 2023-08-15 17:54:48 +02:00
bitfl0wer 8de2aee513
Update test to match code changes 2023-08-13 16:44:58 +02:00
bitfl0wer 33d5675cc4
Change tests to deal with `Arc<RwLock<T>>`'s 2023-08-13 15:54:07 +02:00
bitfl0wer 041ee223c3
Moddify observe to still store T internally 2023-08-13 15:52:16 +02:00
fowb 582d855662 Change T: Updateable to Arc<RwLock<T>> 2023-08-12 22:40:40 +02:00
fowb d28f19d8ca Change observe() to take Arc<RwLock<T>> 2023-08-12 19:47:11 +02:00
fowb b672dd221c Change Mutex<T> to RwLock<T> 2023-08-12 19:31:31 +02:00
bitfl0wer b2a3294b5d
update mutex to rwlock 2023-08-04 20:08:49 +02:00
bitfl0wer 126d411b54
Fix deadlock on test_get_mutual_relationships 2023-08-04 11:42:28 +02:00
bitfl0wer 5926cbb70e
Fix deadlock in test_get_relationships 2023-08-04 11:34:03 +02:00
bitfl0wer 578b4c2fa9
Integrate component behaviour everywhere 2023-08-04 11:19:23 +02:00
kozabrada123 dcb518bd3c Fix the test 2023-07-30 09:10:32 +02:00
kozabrada123 787da3092c Moar docs 2023-07-29 10:23:04 +02:00
Flori fa7dd4b92b
Improve auto updating structs usage (#168)
* Add `GatewayHandle` to `UserMeta`

* Make user::shell async due to gateway add
2023-07-24 19:13:53 +02:00
Flori 38f0659ec9
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
Flori b5a8562d89
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 7df6cb183f
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 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
Vincent Junge 9ccc08b5e2
remove client side validation 2023-06-25 11:36:37 +02:00
Flori Weber 1085cbb462
cargo fix 2023-06-23 12:54:15 +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 4b31fb4ec7
Reflect changes to Channel::modify() in test 2023-06-22 18:55:26 +02:00
Vincent Junge f2709492de
always use Snowflakes in args 2023-06-22 18:55:19 +02:00
Vincent Junge 8d7e49f3c2
get channel messages 2023-06-21 14:46:45 +02:00
Vincent Junge 9429bd7772
more consistent use of snowflakes 2023-06-20 22:03:29 +02:00
Flori dcacfacda9
Merge pull request #117 from SpecificProtagonist/gateway-event
Simplify GatewayEvent
2023-06-20 18:57:13 +02:00
kozabrada123 f2d3aa62e2 Update in tests too 2023-06-20 18:33:37 +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
Flori Weber 603c8c8150
apply clippy suggestions 2023-06-19 19:01:18 +02:00
Flori Weber f7ea86917f
Add block and unblock test 2023-06-19 18:46:49 +02:00
Flori Weber 0a1de13f29
Add a friendship test (:3) 2023-06-19 18: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 6ea587f096
Modift get_mutual, add get_relationships 2023-06-18 15:39:40 +02:00
Flori Weber fb49c589af
Send a friend request 2023-06-18 13:59:11 +02:00
Flori Weber a4be25887b
Implement test_get_mutual_relationships 2023-06-15 18:48:01 +02:00
kozabrada123 dc5e91a784 Reformat and cargo fix 2023-06-11 14:32:37 +02:00
Flori Weber 41135d037f
Cargo fix 2023-06-11 13:54:54 +02:00
Flori Weber 5bbfdc3a09
Cargo clippy --fix 2023-06-11 13:54:08 +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 0563db5562
Add tests for permission modification 2023-06-10 22:26:15 +02:00
Flori Weber e9f1f339d4
Test singular role 2023-06-10 19:42:41 +02:00
Flori Weber a90595c176
Complete this test 2023-06-10 17:35:09 +02:00
kozabrada123 0b06f914e3 Merge branch 'main' into perpetual/gateway-dev 2023-06-10 10:30:54 +02:00
bitfl0wer a9fceedf0f
Add incomplete add_remove_role test 2023-06-10 00:39:04 +02:00
bitfl0wer 83ef21199b
Change test due to common.rs changing 2023-06-10 00:24:08 +02:00
bitfl0wer 9c22d536df
Add role to test bundle 2023-06-10 00:23:49 +02:00
bitfl0wer fde7b4194a
Update test 2023-06-09 21:35:15 +02:00
kozabrada123 182cd45a15 Rebase 2023-06-09 18:14:20 +02:00
bitfl0wer f44e1f5856
Test RoleObject::create() and ::get_all() 2023-06-09 12:03:56 +02:00
bitfl0wer ea69d51574
Add some documentation 2023-06-08 21:53:34 +02:00
kozabrada123 e6af81d694 Basic tests 2023-06-08 19:51:32 +02:00
bitfl0wer b1dbc53049
Refactor channels() 2023-05-29 23:59:13 +02:00
bitfl0wer 3cebafecf6
Refactor create 2023-05-29 23:57:23 +02:00
bitfl0wer d8d3bf5be6
Refactor delete() 2023-05-29 23:51:12 +02:00
bitfl0wer 96ace34137
Refactor create() and get() 2023-05-29 23:46:43 +02:00
bitfl0wer eaf45274a6
Refactor Guild create 2023-05-29 23:16:43 +02:00
bitfl0wer a12573fe1c
Refactor modify() to take less boilerplate args 2023-05-29 23:11:12 +02:00
bitfl0wer 808224d4fb
Refactor delete() to take less boilerplate args 2023-05-29 23:08:52 +02:00
bitfl0wer 001dc9f80c
Refactor get() to take less boilerplate args 2023-05-29 23:01:17 +02:00
bitfl0wer d44193618e
ADd test for modify_channel() 2023-05-29 18:50:09 +02:00
bitfl0wer 6bcbb0e470
Teardown after delete_channel 2023-05-29 18:29:08 +02:00
bitfl0wer 789d7ec7e8
Replace guild_id with guild object 2023-05-29 16:51:41 +02:00
bitfl0wer d51291de3c
Change test delete, add test get_channels() 2023-05-29 16:51:28 +02:00
bitfl0wer 7f6ed72068
Add delete_channel test. 2023-05-28 23:04:56 +02:00
bitfl0wer af9247ed11
Testing on main woah 2023-05-28 00:53:45 +02:00
bitfl0wer 06c49c6895
remove login test 2023-05-27 22:53:40 +02:00
bitfl0wer daf4e923d5
Add instance tests 2023-05-27 22:51:57 +02:00
bitfl0wer c8caf2afb7
Remove newline at beginning of file 2023-05-27 22:47:14 +02:00
bitfl0wer 92af5f09b6
Add message tests 2023-05-27 22:46:57 +02:00
bitfl0wer 8f123c2054
Add auth tests 2023-05-27 22:46:50 +02:00
bitfl0wer 3028d8f70a
move channel test to channel 2023-05-27 22:12:15 +02:00
bitfl0wer c85ac2d663
Move common code into common::<> 2023-05-27 22:12:07 +02:00
bitfl0wer 241afd9003
Rename integration.rs to guild.rs 2023-05-27 22:11:35 +02:00
bitfl0wer 04ae8fdf68
Remove unnecessary import 2023-05-26 12:51:18 +02:00
bitfl0wer 96c7c129f2
Finish refactor 2023-05-26 12:50:16 +02:00
bitfl0wer 8698fce7fc
Fix get_channel test 2023-05-23 16:25:31 +02:00
bitfl0wer 43b099b5eb
Add get_channel integration test 2023-05-23 15:25:47 +02:00
bitfl0wer 8030b7f152
Add teardown() call to guild_creation test 2023-05-23 14:28:45 +02:00
bitfl0wer 9fce6c4606
Delete Guild on test cleanup 2023-05-23 14:00:08 +02:00
bitfl0wer 4b4f863c03
Impl. instance, guild_id, channel to TestBundle 2023-05-23 13:57:02 +02:00
bitfl0wer 0e3e26439d
Add instance, guild, channel to TestBundle 2023-05-23 13:15:57 +02:00
bitfl0wer 301ac320c6
move integration test from guild to integration.rs 2023-05-21 16:02:54 +02:00
bitfl0wer 31ff7b9243
Derive Debug, add comment 2023-05-21 15:51:24 +02:00
bitfl0wer dd6cc2f45e
Register testuser on setup(), delete on teardown() 2023-05-21 15:49:52 +02:00
bitfl0wer 8cb26929ce
Create teardown() 2023-05-21 00:47:40 +02:00
bitfl0wer b5b032c37e
Create integration.rs, is broken right now 2023-05-20 21:04:03 +02:00
bitfl0wer 556976890d
Begin working on setup fn in tests/integration.rs 2023-05-20 12:22:54 +02:00