You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Ignore pushrules in our cached sync response (#571)
* Ignore pushrules in our cached sync response As hopefully explained in the comment
This commit is contained in:
committed by
Luke Barnard
parent
497a2bd057
commit
0143ac2a86
15
src/sync.js
15
src/sync.js
@@ -616,7 +616,7 @@ SyncApi.prototype._sync = async function(syncOptions) {
|
||||
}
|
||||
|
||||
try {
|
||||
await this._processSyncResponse(syncToken, data);
|
||||
await this._processSyncResponse(syncToken, data, isCachedResponse);
|
||||
} catch(e) {
|
||||
// log the exception with stack if we have it, else fall back
|
||||
// to the plain description
|
||||
@@ -699,8 +699,11 @@ SyncApi.prototype._onSyncError = function(err, syncOptions) {
|
||||
* @param {string} syncToken the old next_batch token sent to this
|
||||
* sync request.
|
||||
* @param {Object} data The response from /sync
|
||||
* @param {bool} isCachedResponse True if this response is from our local cache
|
||||
*/
|
||||
SyncApi.prototype._processSyncResponse = async function(syncToken, data) {
|
||||
SyncApi.prototype._processSyncResponse = async function(
|
||||
syncToken, data, isCachedResponse,
|
||||
) {
|
||||
const client = this.client;
|
||||
const self = this;
|
||||
|
||||
@@ -779,7 +782,13 @@ SyncApi.prototype._processSyncResponse = async function(syncToken, data) {
|
||||
client.store.storeAccountDataEvents(events);
|
||||
events.forEach(
|
||||
function(accountDataEvent) {
|
||||
if (accountDataEvent.getType() == 'm.push_rules') {
|
||||
// XXX: This is awful: ignore push rules from our cached sync. We fetch the
|
||||
// push rules before syncing so we actually have up-to-date ones. We do want
|
||||
// to honour new push rules that come down the sync but synapse doesn't
|
||||
// put new push rules in the sync stream when the base rules change, so
|
||||
// if the base rules change, we do need to refresh. We therefore ignore
|
||||
// the push rules in our cached sync response.
|
||||
if (accountDataEvent.getType() == 'm.push_rules' && !isCachedResponse) {
|
||||
client.pushRules = accountDataEvent.getContent();
|
||||
}
|
||||
client.emit("accountData", accountDataEvent);
|
||||
|
||||
Reference in New Issue
Block a user