[WIP] handle events that update Room state#2
Conversation
|
The eventual goal would be feature parity with the js client, correct? If you don't mind I'd like to work on adding the necessary handling and structures, as long as I stay away from the encryption stuff, could I start moving the structs into their own files, something like and as you said in the issue, for each bit of event handling adding a corresponding method on the client. |
Yes, moving those into separate files is a good idea.
We don't necessarily want everything from the js-sdk, it has methods for automatic pagination which were a bit tricky to modify to take events from differing sources since the As for how the SDK should be designed I'm more mimicking matrix-nio which has a layered design with a state machine as the heart of the lib. Ruma plays nicely with our goal of being a layered SDK where the IO transport is only added at the last user facing layer as well. But all of the methods to allow people to easily get user/room display names should be implemented.
The base client already knows how to receive sync responses and forwards events to rooms. Rooms only need to know how to handle each and every event, at least the ones that modify the room state. Please note that we'll want to support a couple of client types:
|
|
Should I start a new PR or just amend the name of this one and the fact that it'll be a WIP? |
|
You can continue on this one. There are a couple of merge conflicts now since I merged the latest crypto work but they seem to be quite easy ones, sorry about that. |
|
Don't worry about me!! |
|
I wanted to see if this works before I merge in all my event addition work... Oh it |
|
Conflicting version for what? We can get those quite often for one of the ruma crates, since they depend on each other, though latest master builds fine for me and travis as well. |
|
Hmm that's odd it seems to have completely gone away, it was something about |
|
Yeah that's a common one, if one of the ruma(-client-api?) crates depends on a different ruma(-api?) version than we do. |
|
Yeah I started using Ok here is my work on folder structure and keeping the |
|
Ok I'm gonna say this is ready for review. A few questions
|
poljar
left a comment
There was a problem hiding this comment.
Mostly looks fine, a couple changes needed. I didn't go into the detail if display name calculation is correct if there are issues with it we can fix them later on and unit tests and real world usage should reveal those soon enough.
| /// If the user should be considered active. | ||
| pub currently_active: Option<bool>, | ||
| /// The events that created the state of the current user. | ||
| // TODO do we want to hold the whole state or just update our structures. |
There was a problem hiding this comment.
I don't know what the right answer is. Redacting membership events is a valid thing to do in Matrix, e.g. if someone changes the display name to something offensive. If we hold the full event chain here we can easily go back to the previous state, though we are not guaranteed to have the full chain anyways. So perhaps holding on to the previous display name and avatar URL and event ids so we know when redactions mess things up is enough. Lets leave it as is for now and optimize later.
| assert!(client.sync_token().await.is_some()); | ||
| } | ||
|
|
||
| #[tokio::test] |
There was a problem hiding this comment.
Could you add some more tests? This already adds quite a bit functionality and we're not covering much.
E.g. room display name calculation isn't tested at all. We track coverage with tarpaulin, it just isn't yet set up for CI.
There was a problem hiding this comment.
I'm having troubles installing tarpaulin but I think I may have just figured it out.
Do you want me to add internal tests for the pub(crate) methods, for Room, RoomMember, the base client, ect.
There was a problem hiding this comment.
If you have the time, sure. The more tests the better.
There was a problem hiding this comment.
I got tarpaulin to install yay! haha stupid libssh
|
I still have to add tests. |
|
the coverage report It appears that |
poljar
left a comment
There was a problem hiding this comment.
I think we can merge after the splitting on : thing is clarified or fixed.
poljar
left a comment
There was a problem hiding this comment.
Looks good, will merge soon.
|
Can I just get a sign-off from you. Just a line stating that you're the author like it's done here. |
|
Signed-off-by: Devin Ragotzy devin.ragotzy@gmail.com |
# This is the 1st commit message: feat(room): add `Room::room_member_updates_sender` This sender will notify receivers when new room members are received: this can happen either when reloading the full room member list from the HS or when new member events arrive during a sync. The sender will emit a `RoomMembersUpdate`, which can be either a full reload or a partial one, including the user ids of the members that changed. # The commit message #2 will be skipped: # Fix test in wasm
Add calculate_room_name(s) methods.