Skip to content

Commit 44528e4

Browse files
committed
fix two bugs surfaced by unban test
1 parent 91b2a83 commit 44528e4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Mjolnir.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ export class Mjolnir {
185185
}
186186

187187
const ruleServer = config.web.ruleServer ? new RuleServer() : null;
188+
188189
const mjolnir = new Mjolnir(
189190
client,
190191
await client.getUserId(),
@@ -199,9 +200,6 @@ export class Mjolnir {
199200
"Mjolnir is starting up. Use !mjolnir to query status.",
200201
);
201202
Mjolnir.addJoinOnInviteListener(mjolnir, client, config);
202-
203-
mjolnir.moderators = new ModCache(mjolnir.client, mjolnir.matrixEmitter, mjolnir.managementRoomId);
204-
205203
return mjolnir;
206204
}
207205

@@ -246,7 +244,8 @@ export class Mjolnir {
246244
}
247245
}
248246

249-
const { msgtype, body: originalBody, sender, event_id } = eventContent;
247+
const { msgtype, body: originalBody, sender } = eventContent;
248+
const eventId = event.event_id;
250249
if (msgtype !== "m.text" || typeof originalBody !== "string") {
251250
return;
252251
}
@@ -278,7 +277,7 @@ export class Mjolnir {
278277
eventContent.body = COMMAND_PREFIX + restOfBody;
279278
LogService.info("Mjolnir", `Command being run by ${sender}: ${eventContent.body}`);
280279

281-
client.sendReadReceipt(roomId, event_id).catch((e: any) => {
280+
client.sendReadReceipt(roomId, eventId).catch((e: any) => {
282281
LogService.warn("Mjolnir", "Error sending read receipt: ", e);
283282
});
284283
return handleCommand(roomId, event, this);
@@ -320,6 +319,8 @@ export class Mjolnir {
320319
this.protectionManager = new ProtectionManager(this);
321320

322321
this.managementRoomOutput = new ManagementRoomOutput(managementRoomId, client, config);
322+
323+
this.moderators = new ModCache(client, matrixEmitter, managementRoomId);
323324
this.protectedRoomsTracker = new ProtectedRoomsSet(
324325
client,
325326
clientUserId,

0 commit comments

Comments
 (0)