Skip to content

Commit d537067

Browse files
committed
Support sync without filters for guest access
1 parent 66e5d6e commit d537067

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/matrix/Sync.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,17 @@ export class Sync {
176176
async _syncRequest(syncToken, timeout, log) {
177177
let {syncFilterId} = this._session;
178178
if (typeof syncFilterId !== "string") {
179-
this._currentRequest = this._hsApi.createFilter(this._session.user.id, {room: {state: {lazy_load_members: true}}}, {log});
180-
syncFilterId = (await this._currentRequest.response()).filter_id;
179+
try {
180+
this._currentRequest = this._hsApi.createFilter(this._session.user.id, {room: {state: {lazy_load_members: true}}}, {log});
181+
syncFilterId = (await this._currentRequest.response()).filter_id;
182+
} catch (err) {
183+
// if the server doesn't support filters, we'll just have to do without
184+
log.log('Sync filters aren\'t available, falling back to no filter');
185+
syncFilterId = "filteringNotAvailable";
186+
}
181187
}
182188
const totalRequestTimeout = timeout + (80 * 1000); // same as riot-web, don't get stuck on wedged long requests
183-
this._currentRequest = this._hsApi.sync(syncToken, syncFilterId, timeout, {timeout: totalRequestTimeout, log});
189+
this._currentRequest = this._hsApi.sync(syncToken, syncFilterId === "filteringNotAvailable" ? undefined : syncFilterId, timeout, {timeout: totalRequestTimeout, log});
184190
const response = await this._currentRequest.response();
185191

186192
const isInitialSync = !syncToken;

0 commit comments

Comments
 (0)