matrix-org / sliding-sync

Proxy implementation of MSC3575's sync protocol.
https://github.com/matrix-org/matrix-spec-proposals/pull/3575
Apache License 2.0
244 stars 37 forks source link

Proxy cannot communicate DM room becoming a non-DM #328

Open DMRobertson opened 1 year ago

DMRobertson commented 1 year ago

The field is a bool, serialised as omitempty

https://github.com/matrix-org/sliding-sync/blob/ce99d0f911fb2e0d75b575ace610bade26433a87/sync3/room.go#L21

which means that a transition true -> false will never be signalled to clients.

In practice nobody changes the DMness of rooms, so this is unlikely to matter.

AFAICS this is where the value that clients will see is set:

https://github.com/matrix-org/sliding-sync/blob/7e4842660c53061159cff2422feafe98269a0ecf/sync3/handler/connstate.go#L684

(indeed there are no other writes to sync3.Room.IsDM).

The corresponding field on UserRoomData is updated when the user cache sees an invite or an "m.direct" room account data event, which seems sensible.

DMRobertson commented 1 year ago

To fix: easy mode is to remove omitempty. Then we'd keep sending down is_dm: false. But we must presumably send down is_dm: true all the time today, so that's fine.

Hard mode is to change sync3.Room.IsDM to be a *bool and only set it to a nonnil value if there is a change in field to report.