-
Notifications
You must be signed in to change notification settings - Fork 333
Federation: support read receipts #1801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2497da0
to
cf94042
Compare
bfae6a1
to
c4bb6c9
Compare
This is a pretty invasive refactoring of code dealing with members of conversations, especially in `Galley.Data`. Here is a summary of changes: - Introduced a `UserList` type, representing a list of users partitioned into locals and remotes. - Removed many of the convenience functions to add members to a conversation. The default admin role functionality is now implemented using a `ToUserRole` type class. - Event creation for adding members or creating conversations is now done outside the `Data` module. This will make it possible to unify the event creation and propagation logic across many conversation endpoints. - Many functions operating on lists have been generalised to `Foldable`, so they can work uniformly with `UserList`s and normal lists. - The `ConvSizeChecked` newtype was broken, because the `Functor` instance would allow to break the invariant encoded by the type. This is now fixed, and the type can now wrap an arbitrary `Foldable`. - Similar changes have been applied to `ConvMemberAddSizeChecked`. - Support for creating managed conversations has been dropped
This further separates the self member update code path from the other member update. There was really no reason to have them together in the first place.
The core of the unified interface is the `updateLocalConversation` function, which performs an update and notifies local and remote users. **Note**: the remove member update is a bit special, because it was implemented using checked exceptions. To make it compatible with the other updates, checked exceptions are not currently used, although they are still present in some type signatures. To make the unification possible, a number of other changes were necessary: - Removed checked add member wrapper. This wasn't either safe (because it didn't encompass all the necessary size checks) nor necessary (because the checks were already performed by `ensureMemberLimit`). - Aligned conversation update RPC to endpoint interface. The generalised RPC interface is not necessary for now (it can always be regeneralised later if needed), and making it the same as the public interface simplifies some things. - Added some general code to deal with local and remote members uniformly. This simplifies many functions that can operate on both local and remote members. For example member removal, which is also used for leaving a remote conversation.
A leave action is a special case of a member remove action, but it has a different "tag", so now `conversationActionTag` takes the originating user as an extra argument, and retuns a `LeaveConversation` tag for `ConversationActionRemoveMember` actions that remove the originating user. This also fixes legalhold-related failures when non-consenting users are removed after legal hold is enabled.
Creating managed conversations is not supported anymore
8249bc8
to
edb1772
Compare
My first thought was "that should have been split up, then!". My second, 200ms later: "this keeps happening to me, too, why is this so hard?!" :) |
It requires a lot of discipline to keep changes separated when refactoring things on a larger scale, and I don't always have it. It wouldn't be impossible to carefully split the changes into meaningful commits after the fact, but it would take considerable time, and I thought it might be better spent for other things. |
Co-authored-by: Marko Dimjašević <[email protected]>
Before, we were checking whether the number of people added to a conversation was strictly less than the limit - 1, which was causing conversation with maximum size to be rejected. This was introduced by the refactoring in #1801.
* Fix check on conversation size Before, we were checking whether the number of people added to a conversation was strictly less than the limit - 1, which was causing conversation with maximum size to be rejected. This was introduced by the refactoring in #1801. * Add test about conversation size limit Added a test checking that creating conversations of exactly the size limit is allowed.
The initial purpose of this PR was to add federation behaviour for receipt mode update, which it does. However, in an effort to avoid copy-pasting code, it also unifies all the federation-aware conversation update code paths, and as a consequence the diff ended up being quite large.
The core of the unified interface is the
updateLocalConversation
function, which performs an update and notifies local and remote users.Note: the remove member update is a bit special, because it was implemented using checked exceptions. To make it compatible with the other updates, checked exceptions are not currently used, although they are still present in some type signatures.
To make the unification possible, a number of other changes were necessary:
ensureMemberLimit
).UserList
type, representing a list of users partitioned into locals and remotes.ToUserRole
type class.Data
module. This will make it possible to unify the event creation and propagation logic across many conversation endpoints.Foldable
, so they can work uniformly withUserList
s and normal lists.ConvSizeChecked
newtype was broken, because theFunctor
instance would allow to break the invariant encoded by the type. This is now fixed, and the type can now wrap an arbitraryFoldable
.This is part of https://wearezeta.atlassian.net/browse/SQCORE-885 (federated conversation metadata updates).
Checklist
changelog.d
.