Commit Graph

842 Commits

Author SHA1 Message Date
bitfl0wer 2fe95ccc06
Add JsonField derive 2023-08-04 16:41:37 +02:00
Flori a51d524f46
Components and Composites (#175)
As described in #165 , Gateway induced changes of entity structs do not
get propagated to other structs holding the "same" object which got
updated. This is bad because it means that structs still hold
potentially outdated info.

My proposed solution is to create components and composites. A component
is an object with information which is supposed to be the same in at
least 2 structs, such as a Channel object ("channels" field in Guild
struct and lone Channel object for example). These components should be
shared instead of cloned, to make sure that an update to this shared
structs fields is reflected everywhere the struct is being used.

We can do this by using `Arc<Mutex<T>>`. Mutex can be the
std::sync::Mutex, as long as locks on the components themselves are not
being held across .await points. ~~This draft is not yet finished, but~~
all instances of components in composite entity structs have been
replaced with their `Arc<Mutex<T>>` counterparts already.
2023-08-04 15:55:47 +02:00
Flori f74214e181
Merge pull request #1 from kozabrada123/prototype/component-and-composites
Re-add derives to structs where possible
2023-08-04 15:48:34 +02:00
kozabrada123 4d0f27a668 Re-add derives to structs where possible 2023-08-04 15:33:46 +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
bitfl0wer 96213aaf24
Make components be Arc<Mutex<T>> 2023-08-02 23:08:53 +02:00
bitfl0wer 2bfdf4e3e9
Add PartialEq, Eq, Hash to Enums 2023-08-02 20:23:50 +02:00
bitfl0wer 5d66ad83f2
Start component-izing entities, remove PartialEq wherever needed (because PartialEq isn't implemented for Mutex) 2023-08-02 20:18:16 +02:00
bitfl0wer 1bb91251f5
Add rc feature to serde 2023-08-02 20:17:36 +02:00
bitfl0wer 076887938f
Exclude all Target dirs 2023-08-01 21:21:00 +02:00
Flori 80dac3b7a1
Doc comment improvements (#171)
This pr is focused on improving doc comments, along with some minor
changes

Changes (up to now):
- Make all doc comments use `///`
- Fix links (links that aren't actually links, links such as
`[https://discord.com](https://discord.com)` -> `<https://discord.com>`)
- Remove unnecessary docs that only restate what the function signature
already says
- Document some previously undocumented types
- Change `Result<_, crate::errors::ChorusError>` to `ChorusResult<_>`
- Rename `create_guild_invite` to `create_channel_invite` (See the
surrounding code and the endpoint used)

Should close #129
2023-07-31 22:37:23 +02:00
kozabrada123 6cbde1a04b Fix missing references to the best of my ability 2023-07-31 10:28:18 +02:00
kozabrada123 9f39943b15 Goof 2023-07-31 10:07:56 +02:00
kozabrada123 4e4e279333 Docs 2023-07-31 10:01:25 +02:00
kozabrada123 abb3c7e0e6 Merge branch 'main' into fix/doc-improvements 2023-07-31 09:13:33 +02:00
Flori 911dcc5d83
Changed struct reaction (#173)
Fixes #172
2023-07-30 20:35:32 +02:00
Flori 18faea5aad
Remove newline 2023-07-30 20:35:02 +02:00
Vivien 6ec26feffb update of reaction struct 2023-07-30 20:27:13 +02:00
Vivien 909f1c0285 change signed to unsigned integer 2023-07-30 20:23:12 +02:00
kozabrada123 dcb518bd3c Fix the test 2023-07-30 09:10:32 +02:00
kozabrada123 b99bcef1f6 Guilds + Channels 2023-07-30 09:04:31 +02:00
kozabrada123 51679e773c Fix broken links 2023-07-30 08:31:12 +02:00
kozabrada123 499faefa51 Documemtaiom 2023-07-30 08:26:26 +02:00
kozabrada123 b897e44cca Document a small bit of attachment 2023-07-29 18:12:57 +02:00
kozabrada123 1893dfe0f9 Permissions with code blocks 2023-07-29 18:12:57 +02:00
kozabrada123 49801bef10
Update src/types/utils/rights.rs
Co-authored-by: SpecificProtagonist <specificprotagonist@posteo.org>
2023-07-29 16:07:06 +00:00
kozabrada123 8954fd2ae5
Update src/types/utils/snowflake.rs
Co-authored-by: SpecificProtagonist <specificprotagonist@posteo.org>
2023-07-29 16:06:49 +00:00
kozabrada123 5ed24eea62
Update src/types/utils/rights.rs
Co-authored-by: SpecificProtagonist <specificprotagonist@posteo.org>
2023-07-29 16:06:35 +00:00
kozabrada123 d4048d8845
Update src/types/utils/rights.rs
Co-authored-by: SpecificProtagonist <specificprotagonist@posteo.org>
2023-07-29 16:05:27 +00:00
kozabrada123 5d49e72461
Update src/types/utils/rights.rs
Co-authored-by: SpecificProtagonist <specificprotagonist@posteo.org>
2023-07-29 16:04:49 +00:00
kozabrada123 b4b9f87520
Capitalise docs
Co-authored-by: SpecificProtagonist <specificprotagonist@posteo.org>
2023-07-29 16:04:08 +00:00
kozabrada123 abcdd5e128 Forgot this since had the lint on my local copy 2023-07-29 11:45:25 +02:00
kozabrada123 9c4136644b Document some flags 2023-07-29 11:26:10 +02:00
kozabrada123 a4f59fcdf4 Minor doc changes 2023-07-29 11:26:00 +02:00
kozabrada123 3058025e9d Document rights 2023-07-29 11:00:28 +02:00
kozabrada123 787da3092c Moar docs 2023-07-29 10:23:04 +02:00
kozabrada123 a2ddafb6a1 Remove the todos from the last commit 2023-07-28 18:57:35 +02:00
kozabrada123 1f9efa98e3 Better docs 2023-07-28 18:45:40 +02:00
kozabrada123 577c8a2d71 Merge branch 'main' into fix/doc-improvements 2023-07-28 18:21:20 +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
SpecificProtagonist 24450571de
derive Updateable (#167) 2023-07-22 11:20:31 +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
kozabrada123 260dd320a8 Merge stuff 2023-07-21 14:10:50 +02:00
SpecificProtagonist f97d26bc6c
Fix gateway heartbeat blocking (#162)
fix gateway heartbeat blocking
2023-07-21 13:59:40 +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 9953d9e299
Bump crate versions (#158) 2023-07-17 20:06:57 +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 5f5e56d1ca
Update code-ql action to v2 2023-07-17 19:35:16 +02:00