-
Notifications
You must be signed in to change notification settings - Fork 38
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
Add timestamp
to room responses
#247
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there, thanks.
sync3/handler/connstate.go
Outdated
@@ -624,6 +624,7 @@ func (s *ConnState) getInitialRoomData(ctx context.Context, roomSub sync3.RoomSu | |||
JoinedCount: metadata.JoinCount, | |||
InvitedCount: &metadata.InviteCount, | |||
PrevBatch: userRoomData.RequestedLatestEvents.PrevBatch, | |||
Timestamp: metadata.LastMessageTimestamp, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't know if this is what they want. getInitialRoomData
is a central point called for multiple lists: you need to know the bump_event_types
values to know what timestamp to pull here. Add that as a param to getInitialRoomData
sync3/handler/connstate_live.go
Outdated
@@ -187,6 +187,14 @@ func (s *connStateLive) processLiveUpdate(ctx context.Context, up caches.Update, | |||
// include this update in the rooms response TODO: filters on event type? | |||
userRoomData := roomUpdate.UserRoomMetadata() | |||
r := response.Rooms[roomUpdate.RoomID()] | |||
|
|||
conMeta := s.lists.ReadOnlyRoom(roomUpdate.RoomID()) | |||
for _, ts := range conMeta.LastInterestedEventTimestamps { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs comments. This is using the highest timestamp from each list for this room I guess?
tests-e2e/timestamp_test.go
Outdated
|
||
// Bob should see a different timestamp than alice, as he just joined | ||
bobTimestampBefore := resBob.Rooms[roomID].Timestamp | ||
if bobTimestampBefore == timestampBeforeBobJoined { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really this should equal res.Rooms[roomID].Timestamp
as that is going to be bob's join due to :30.
tests-e2e/timestamp_test.go
Outdated
|
||
resBob = bob.SlidingSyncUntilEventID(t, resBob.Pos, roomID, eventID) | ||
bobTimestampAfter = resBob.Rooms[roomID].Timestamp | ||
if bobTimestampBefore == bobTimestampAfter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, we need to know exactly what timestamp this should be - use alice to figure this out.
if bobTimestampBefore != bobTimestampAfter { | ||
t.Fatalf("expected timestamps to be the same, but they aren't: %v vs %v", bobTimestampBefore, bobTimestampAfter) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs more tests. Specifically:
- If you now do an initial sync (no pos) as Bob with the same lists, I don't think you'll get the right value. You'll get the latest timestamp (m.room.name) and not the m.reaction timestamp.
- Ensure you
time.Sleep(time.Millisecond)
after each send to ensure that timestamps will change. - If Charlie now joins the room with the same bump_event_types as bob, he should see the timestamp of his join.
This has been added in matrix-org/sliding-sync#247. This is not part of the MSC yet.
This has been added in matrix-org/sliding-sync#247. This is not part of the MSC yet.
This has been added in matrix-org/sliding-sync#247. This is not part of the MSC yet.
… sorting (#17395) `bump_stamp` corresponds to the `stream_ordering` of the latest `DEFAULT_BUMP_EVENT_TYPES` in the room. This helps clients sort more readily without them needing to pull in a bunch of the timeline to determine the last activity. `bump_event_types` is a thing because for example, we don't want display name changes to mark the room as unread and bump it to the top. For encrypted rooms, we just have to consider any activity as a bump because we can't see the content and the client has to figure it out for themselves. Outside of Synapse, `bump_stamp` is just a free-form counter so other implementations could use `received_ts`or `origin_server_ts` (see the [*Security considerations* section in MSC3575 about the potential pitfalls of using `origin_server_ts`](https://github.com/matrix-org/matrix-spec-proposals/blob/kegan/sync-v3/proposals/3575-sync.md#security-considerations)). It doesn't have any guarantee about always going up. In the Synapse case, it could go down if an event was redacted/removed (or purged in cases of retention policies). In the future, we could add `bump_event_types` as [MSC3575](matrix-org/matrix-spec-proposals#3575) mentions if people need to customize the event types. --- In the Sliding Sync proxy, a similar [`timestamp` field was added](matrix-org/sliding-sync#247) for the same purpose but the name is not obvious what it pertains to or what it's for. The `timestamp` field was also added to Ruma in ruma/ruma#1622
Attempt for #245