diff --git a/config/config.sample.yaml b/config/config.sample.yaml index 146668def098cd7a639b253fb4cf49030c6ea3b3..a899c18988e333811e3b65c8012500eb98c5cd5f 100644 --- a/config/config.sample.yaml +++ b/config/config.sample.yaml @@ -24,6 +24,9 @@ bridge: # Enable users to bridge rooms using !discord commands. See # https://t2bot.io/discord for instructions. enableSelfServiceBridging: false + # Disable sending of read receipts for Matrix events which have been + # successfully bridged to Discord. + disableReadReceipts: false # Authentication configuration for the discord bot. auth: clientID: "12345" diff --git a/config/config.schema.yaml b/config/config.schema.yaml index 17b816ca6060f16f7bd0cd4e6872ce2c9d102a08..9a35f4b26cee167a0a94009d4614be1c70d127e9 100644 --- a/config/config.schema.yaml +++ b/config/config.schema.yaml @@ -20,6 +20,8 @@ properties: type: "boolean" enableSelfServiceBridging: type: "boolean" + disableReadReceipts: + type: "boolean" auth: type: "object" required: ["botToken", "clientID"] diff --git a/src/bot.ts b/src/bot.ts index 5c151ede8f56fb483deade4baae0ff2879639f81..5b1ccec2f0010b51dfbd66eb7bdd4fa45785bb8e 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -321,6 +321,13 @@ export class DiscordBot { evt.ChannelId = channel.id; await this.store.Insert(evt); }); + if (!this.config.bridge.disableReadReceipts) { + try { + await this.bridge.getIntent().sendReadReceipt(event.room_id, event.event_id); + } catch (err) { + log.error(`Failed to send read receipt for ${event}. `, err); + } + } } public async ProcessMatrixMsgEvent(event: IMatrixEvent, guildId: string, channelId: string): Promise<void> { @@ -393,6 +400,13 @@ export class DiscordBot { evt.ChannelId = channelId; await this.store.Insert(evt); }); + if (!this.config.bridge.disableReadReceipts) { + try { + await this.bridge.getIntent().sendReadReceipt(event.room_id, event.event_id); + } catch (err) { + log.error(`Failed to send read receipt for ${event}. `, err); + } + } return; } diff --git a/src/config.ts b/src/config.ts index c5dfb88b5bba1b70d81cd647da0e8f8923381211..a94c720f9f1ed9dbc86b06829594090ef136172a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -35,6 +35,7 @@ class DiscordBridgeConfigBridge { public disableDiscordMentions: boolean; public disableDeletionForwarding: boolean; public enableSelfServiceBridging: boolean; + public disableReadReceipts: boolean; public disableEveryoneMention: boolean = false; public disableHereMention: boolean = false; }