You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove the need to call /initialSync in getMessagesByUserIn. (#297)
* Remove the need to call `/initialSync` in `getMessagesByUserIn`.
At the moment we call `/initialSync` to give a `from` token to `/messages`.
In this PR we instead do not provide a `from` token when calling `/messages`,
which has recently been permitted in the spec
Technically this is still unstable in the spec
https://spec.matrix.org/unstable/client-server-api/#get_matrixclientv3roomsroomidmessagesmatrix-org/matrix-spec#1002
Synapse has supported this for over 2 years and Element web depends on it for threads.
matrix-org/matrix-js-sdk#2065
Given that redactions are super heavy in Mjolnir already and have been reported
as barely functional on matrix.org I believe we should also adopt this approach as
if for some reason the spec did change before the next release (1.3) (extremely unlikely) we can revert this commit.
// If we are using a glob, there may be no relevant events in this chunk.
179
+
if(events.length>0){
180
+
awaitcb(events);
188
181
}
189
-
}else{
190
-
thrownewError(`Internal Error: rooms/initialSync did not return a pagination chunk for ${roomId}, this is not normal and if it is we need to stop using it. See roomInitialSync() for why we are using it.`);
191
-
}
182
+
// This check exists only because of a Synapse compliance bug https://github.com/matrix-org/synapse/issues/12102.
183
+
// We also check after processing events as the `previousToken` can be 'null' if we are at the start of the steam
184
+
// and `token` can also be 'null' as we have paginated the entire timeline, but there would be unprocessed events in the
185
+
// chunk that was returned in this request.
186
+
if(previousToken===token){
187
+
LogService.debug("utils","Backfill returned same end token - returning early.");
0 commit comments