Skip to content

Commit 1fbeda0

Browse files
committed
Stop MatrixReactionHandler reacting to itself.
1 parent 492230d commit 1fbeda0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/Mjolnir.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export class Mjolnir {
183183
) {
184184
this.protectedRoomsConfig = new ProtectedRoomsConfig(client);
185185
this.policyListManager = new PolicyListManager(this);
186-
this.reactionHandler = new MatrixReactionHandler(this.managementRoomId, client);
186+
this.reactionHandler = new MatrixReactionHandler(this.managementRoomId, client, clientUserId);
187187

188188
const mutedModules = (LogService as any).mutedModules;
189189
if (!Array.isArray(mutedModules)) {

src/commands/interface-manager/MatrixReactionHandler.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ export class MatrixReactionHandler extends EventEmitter {
2929
/**
3030
* A client to lookup the related events to reactions.
3131
*/
32-
private readonly client: MatrixSendClient
32+
private readonly client: MatrixSendClient,
33+
/**
34+
* The user id of the client. Ignores reactions from this user
35+
*/
36+
private readonly clientUserId: string
3337
) {
3438
super();
3539
this.listener = this.handleEvent.bind(this);
@@ -53,6 +57,9 @@ export class MatrixReactionHandler extends EventEmitter {
5357
if (relatesTo['rel_type'] !== 'm.annotation') {
5458
return;
5559
}
60+
if (event['sender'] === this.clientUserId) {
61+
return;
62+
}
5663
const reactionKey = relatesTo['key'];
5764
const relatedEventId = relatesTo['event_id'];
5865
if (!(typeof relatedEventId === 'string' && typeof reactionKey === 'string')) {

0 commit comments

Comments
 (0)