Skip to content

Commit

Permalink
Merge pull request #1318 from matrix-org/bwindels/fixindexernotifs
Browse files Browse the repository at this point in the history
Fix: prevent spurious notifications from indexer
  • Loading branch information
bwindels authored Apr 15, 2020
2 parents a21c625 + 8a460c2 commit d59d62f
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -5265,17 +5265,20 @@ function _resolve(callback, resolve, res) {
resolve(res);
}

function _PojoToMatrixEventMapper(client) {
function _PojoToMatrixEventMapper(client, options) {
const preventReEmit = Boolean(options && options.preventReEmit);
function mapper(plainOldJsObject) {
const event = new MatrixEvent(plainOldJsObject);
if (event.isEncrypted()) {
client.reEmitter.reEmit(event, [
"Event.decrypted",
]);
if (!preventReEmit) {
client.reEmitter.reEmit(event, [
"Event.decrypted",
]);
}
event.attemptDecryption(client._crypto);
}
const room = client.getRoom(event.getRoomId());
if (room) {
if (room && !preventReEmit) {
room.reEmitter.reEmit(event, ["Event.replaced"]);
}
return event;
Expand All @@ -5284,10 +5287,12 @@ function _PojoToMatrixEventMapper(client) {
}

/**
* @param {object} [options]
* @param {bool} options.preventReEmit don't reemit events emitted on an event mapped by this mapper on the client
* @return {Function}
*/
MatrixClient.prototype.getEventMapper = function() {
return _PojoToMatrixEventMapper(this);
MatrixClient.prototype.getEventMapper = function(options = undefined) {
return _PojoToMatrixEventMapper(this, options);
};

/**
Expand Down

0 comments on commit d59d62f

Please sign in to comment.