You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2026-01-03 23:22:30 +03:00
Support guest room filters
This commit is contained in:
26
lib/sync.js
26
lib/sync.js
@@ -190,8 +190,8 @@ SyncApi.prototype.sync = function() {
|
||||
}
|
||||
|
||||
if (client.isGuest()) {
|
||||
// no push rules for guests
|
||||
getFilter();
|
||||
// no push rules for guests, no access to POST filter for guests.
|
||||
self._sync({});
|
||||
}
|
||||
else {
|
||||
getPushRules();
|
||||
@@ -210,8 +210,13 @@ SyncApi.prototype._sync = function(syncOptions, attempt) {
|
||||
var self = this;
|
||||
attempt = attempt || 1;
|
||||
|
||||
var filterId = syncOptions.filterId;
|
||||
if (client.isGuest() && !filterId) {
|
||||
filterId = this._getGuestFilter();
|
||||
}
|
||||
|
||||
var qps = {
|
||||
filter: syncOptions.filterId,
|
||||
filter: filterId,
|
||||
timeout: this.opts.pollTimeout,
|
||||
since: client.store.getSyncToken() || undefined // do not send 'null'
|
||||
};
|
||||
@@ -223,10 +228,6 @@ SyncApi.prototype._sync = function(syncOptions, attempt) {
|
||||
qps.timeout = 1;
|
||||
}
|
||||
|
||||
if (client._guestRooms && client._isGuest) {
|
||||
qps.room_id = client._guestRooms;
|
||||
}
|
||||
|
||||
client._http.authedRequestWithPrefix(
|
||||
undefined, "GET", "/sync", qps, undefined, httpApi.PREFIX_V2_ALPHA,
|
||||
this.opts.pollTimeout + BUFFER_PERIOD_MS // normal timeout= plus buffer time
|
||||
@@ -543,7 +544,18 @@ SyncApi.prototype._processRoomEvents = function(room, stateEventList,
|
||||
// execute the timeline events, this will begin to diverge the current state
|
||||
// if the timeline has any state events in it.
|
||||
room.addEventsToTimeline(timelineEventList);
|
||||
};
|
||||
|
||||
SyncApi.prototype._getGuestFilter = function() {
|
||||
var guestRooms = this.client._guestRooms; // FIXME: horrible gut-wrenching
|
||||
if (!guestRooms) {
|
||||
return "{}";
|
||||
}
|
||||
return JSON.stringify({
|
||||
room: {
|
||||
rooms: guestRooms
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function retryTimeMsForAttempt(attempt) {
|
||||
|
||||
Reference in New Issue
Block a user