This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Implement MSC3391: Removing account data #14244
Labels
O-Occasional
Affects or can be seen by some users regularly or most users rarely
T-Enhancement
New features, changes in functionality, improvements in performance, or user-facing enhancements.
Z-PS-Backend
The Professional Services team at Element plan to see this through.
Z-Time-Tracked
Element employees should track their time spent on this issue/PR.
Add an experimental implementation for MSC3391, which allows users to remove keys from their user and room account data.
TODO
Base behaviour
msc3391_enabled
to guard the feature behind.DELETE /_matrix/client/unstable/org.matrix.msc3391/user/{userId}/account_data/{type}
DELETE /_matrix/client/unstable/org.matrix.msc3391/user/{userId}/rooms/{roomId}/account_data/{type}
type
is removed from the user's user/room account data. This should be recorded in theaccount_data
androom_account_data
tables respectively, by setting the content of each to{}
.{}
when callingPUT /_matrix/client/v3/user/{userId}/account_data/{type}
andPUT /_matrix/client/v3/user/{userId}/rooms/{roomId}/account_data/{type}
will be equivalent to calling theDELETE
endpoint for that type. This is for backwards-compatibility with older clients which have used this to effectively "delete" keys in the past.{}
appear down/sync
after an account data entry is deleted.Permanently deleting items from the account data stream
The
account_data
androom_account_data
tables are simply streams that track all changes to account data items. It would be nice to remove deleted rows from these tables when they're no longer needed (i.e. when every user's device has seen that the delete occurred). We can do so by tracking which devices have seen the change.Note that account data changes through
GET /_matrix/client/{r0,v3}/events
are ignored for now. The endpoint has long been deprecated and supporting this requires a non-trivial amount of changes (namely passing a device ID intoAccountDataEventSource.get_new_events
).Add a new table
account_data_undelivered_deletes
, which tracks whether a device has seen the deletion. Upon a delete one row for each known user device is added to this table. Upon a device sync'ing the changeor hitting the(axed, as it's weird that calling this may prevent the delete from coming downGET
endpoint for the data/sync
- expanded upon in this comment), the relevant row will be removed. Note that "sync'ing a change" here is defined as a device using asince
token with an account data stream ID that is after the account data entry in question, otherwise we can't be sure that the client has really seen the change (credit to Olivier for this point). Once all devices of a user have seen a deletion, we can delete the key from theaccount_data
orroom_account_data
table. The device that caused the deletion should not have a row inserted.The
account_data_undelivered_deletes
table has the following schema:Add entries to
account_data_undelivered_deletes
for each device of a user when an account data entry is deleted.Adding content to an account data type should clear all relevant rows in
account_data_undelivered_deletes
as that type is no longer in a deleted state.Delete entries in
account_data_undelivered_deletes
when a given device knows that delete has occurred (through/sync
).Permanently delete all data from the
account_data
orroom_account_data
tables related to a given (account_data_type, user_id) pair when all user devices have seen the delete (the last relevant row has been removed fromaccount_data_undelivered_deletes
).This will be done by a background job - it's relatively easy to compute all {user,room} account data items with an empty content that do not have a corresponding entry in
account_data_undelivered_deletes
and there are no theoretical race conditions with this cleanup occurring on a periodic timer.Deleting a device should remove all relevant rows from the
account_data_undelivered_deletes
table. (hint: usepurge_account_data_for_user
)Possibly update the relevant account data Synapse module callback documentation.
Tests
cc @ShadowJonathan
The text was updated successfully, but these errors were encountered: