Ack bridged Matrix events

May provide reassurance that the bridge is currently working.
Half-Shot's bridge has always done this.
This commit is contained in:
Cadence Ember
2025-01-08 01:31:31 +13:00
parent 93cacba283
commit 7e6548eb90
2 changed files with 25 additions and 0 deletions

View File

@@ -104,6 +104,7 @@ async event => {
// @ts-ignore
await matrixCommandHandler.execute(event)
}
await api.ackEvent(event)
}))
sync.addTemporaryListener(as, "type:m.sticker", guard("m.sticker",
@@ -113,6 +114,7 @@ sync.addTemporaryListener(as, "type:m.sticker", guard("m.sticker",
async event => {
if (utils.eventSenderIsFromDiscord(event.sender)) return
const messageResponses = await sendEvent.sendEvent(event)
await api.ackEvent(event)
}))
sync.addTemporaryListener(as, "type:m.reaction", guard("m.reaction",
@@ -137,6 +139,7 @@ sync.addTemporaryListener(as, "type:m.room.redaction", guard("m.room.redaction",
async event => {
if (utils.eventSenderIsFromDiscord(event.sender)) return
await redact.handle(event)
await api.ackEvent(event)
}))
sync.addTemporaryListener(as, "type:m.room.avatar", guard("m.room.avatar",

View File

@@ -347,6 +347,26 @@ function getMedia(mxc, init = {}) {
})
}
/**
* Updates the m.read receipt in roomID to point to eventID.
* This doesn't modify m.fully_read, which matches [the behaviour of matrix-bot-sdk.](https://github.com/element-hq/matrix-bot-sdk/blob/e72a4c498e00c6c339a791630c45d00a351f56a8/src/MatrixClient.ts#L1227)
* @param {string} roomID
* @param {string} eventID
* @param {string?} [mxid]
*/
async function sendReadReceipt(roomID, eventID, mxid) {
await mreq.mreq("POST", path(`/client/v3/rooms/${roomID}/receipt/m.read/${eventID}`, mxid), {})
}
/**
* Acknowledge an event as read by calling api.sendReadReceipt on it.
* @param {Ty.Event.Outer<any>} event
* @param {string?} [mxid]
*/
async function ackEvent(event, mxid) {
await sendReadReceipt(event.room_id, event.event_id, mxid)
}
module.exports.path = path
module.exports.register = register
module.exports.createRoom = createRoom
@@ -373,3 +393,5 @@ module.exports.setUserPower = setUserPower
module.exports.setUserPowerCascade = setUserPowerCascade
module.exports.ping = ping
module.exports.getMedia = getMedia
module.exports.sendReadReceipt = sendReadReceipt
module.exports.ackEvent = ackEvent