diff --git a/src/bot.ts b/src/bot.ts index 8e0ccfb37c19df2f523d68e0bccf0222b83159f8..235777096b1f388061e4608005d0688996533770 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -1223,15 +1223,18 @@ export class DiscordBot { public async OnMessageReactionAdd(reaction: Discord.MessageReaction, user: Discord.User | Discord.PartialUser) { const message = reaction.message; - const reactionName = reaction.emoji.name; - log.verbose(`Got message reaction add event for ${message.id} with ${reactionName}`); + log.info(`Got message reaction add event for ${message.id} with ${reaction.emoji.name}`); let rooms: string[]; try { rooms = await this.channelSync.GetRoomIdsFromChannel(message.channel); + + if (rooms === null) { + throw Error(); + } } catch (err) { - log.verbose(`No bridged rooms to forward reaction to. Reaction Event: ${reaction}`); + log.verbose("No bridged rooms to send message to. Oh well."); MetricPeg.get.requestOutcome(message.id, true, "dropped"); return; } @@ -1245,7 +1248,6 @@ export class DiscordBot { }); if (!storeEvent?.Result) { - log.verbose(`Received add reaction event for untracked message. Dropping! Reaction Event: ${reaction}`); return; } @@ -1256,7 +1258,7 @@ export class DiscordBot { const reactionEventId = await intent.underlyingClient.unstableApis.addReactionToEvent( room, matrixIds[0], - reaction.emoji.id ? `:${reactionName}:` : reactionName + reaction.emoji.id ? `:${reaction.emoji.name}:` : reaction.emoji.name ); const event = new DbEvent(); @@ -1274,7 +1276,7 @@ export class DiscordBot { public async OnMessageReactionRemove(reaction: Discord.MessageReaction, user: Discord.User | Discord.PartialUser) { const message = reaction.message; - log.verbose(`Got message reaction remove event for ${message.id} with ${reaction.emoji.name}`); + log.info(`Got message reaction remove event for ${message.id} with ${reaction.emoji.name}`); const intent = this.GetIntentFromDiscordMember(user); await intent.ensureRegistered(); @@ -1285,7 +1287,6 @@ export class DiscordBot { }); if (!storeEvent?.Result) { - log.verbose(`Received remove reaction event for untracked message. Dropping! Reaction Event: ${reaction}`); return; } @@ -1308,7 +1309,6 @@ export class DiscordBot { }); if (!event) { - log.verbose(`Received remove reaction event for tracked message where the add reaction event was not bridged. Dropping! Reaction Event: ${reaction}`); return; } @@ -1328,14 +1328,13 @@ export class DiscordBot { } public async OnMessageReactionRemoveAll(message: Discord.Message | Discord.PartialMessage) { - log.verbose(`Got message reaction remove all event for ${message.id}`); + log.info(`Got message reaction remove all event for ${message.id}`); const storeEvent = await this.store.Get(DbEvent, { discord_id: message.id, }); if (!storeEvent?.Result) { - log.verbose(`Received remove all reaction event for untracked message. Dropping! Event: ${message}`); return; } @@ -1349,9 +1348,7 @@ export class DiscordBot { "m.annotation" ); - const filteredChunk = chunk.filter((event) => event.sender === this.bridge.botUserId); - - await Promise.all(filteredChunk.map(async (event) => { + await Promise.all(chunk.map(async (event) => { try { return await underlyingClient.redactEvent(event.room_id, event.event_id); } catch (ex) { diff --git a/src/db/dbdataevent.ts b/src/db/dbdataevent.ts index 5d8fd9e545be5f176005b9830d35ad12433bc855..38738a55352c64a9d4d90c75acc1f896713402cb 100644 --- a/src/db/dbdataevent.ts +++ b/src/db/dbdataevent.ts @@ -19,7 +19,7 @@ import { IDbDataMany } from "./dbdatainterface"; import { ISqlCommandParameters } from "./connector"; export class DbEvent implements IDbDataMany { - /** ID associated with the event in the format "MatrixID:RoomID". */ + /** Matrix ID of event. */ public MatrixId: string; /** Discord ID of the relevant message associated with this event. */ public DiscordId: string;