Stop MatrixReactionHandler reacting to itself.

This commit is contained in:
gnuxie authored and Gnuxie committed 2023-03-24 18:57:25 +00:00
1 parent 492230d61d
commit 1fbeda0d4c
2 files changed
+9 -2

No files matched your search

+1 -1
View File
@@ -183,7 +183,7 @@ export class Mjolnir {
) {
this.protectedRoomsConfig = new ProtectedRoomsConfig(client);
this.policyListManager = new PolicyListManager(this);
this.reactionHandler = new MatrixReactionHandler(this.managementRoomId, client);
this.reactionHandler = new MatrixReactionHandler(this.managementRoomId, client, clientUserId);
const mutedModules = (LogService as any).mutedModules;
if (!Array.isArray(mutedModules)) {
@@ -29,7 +29,11 @@ export class MatrixReactionHandler extends EventEmitter {
/**
* A client to lookup the related events to reactions.
*/
private readonly client: MatrixSendClient
private readonly client: MatrixSendClient,
/**
* The user id of the client. Ignores reactions from this user
*/
private readonly clientUserId: string
) {
super();
this.listener = this.handleEvent.bind(this);
@@ -53,6 +57,9 @@ export class MatrixReactionHandler extends EventEmitter {
if (relatesTo['rel_type'] !== 'm.annotation') {
return;
}
if (event['sender'] === this.clientUserId) {
return;
}
const reactionKey = relatesTo['key'];
const relatedEventId = relatesTo['event_id'];
if (!(typeof relatedEventId === 'string' && typeof reactionKey === 'string')) {