Indicate that errors may be retried
This commit is contained in:
parent
7f7a366cd5
commit
9b37705a73
1 changed files with 10 additions and 1 deletions
|
|
@ -148,7 +148,7 @@ async function sendError(roomID, source, type, e, payload) {
|
||||||
|
|
||||||
// Send
|
// Send
|
||||||
try {
|
try {
|
||||||
await api.sendEvent(roomID, "m.room.message", {
|
const errorEventID = await api.sendEvent(roomID, "m.room.message", {
|
||||||
...builder.get(),
|
...builder.get(),
|
||||||
"moe.cadence.ooye.error": {
|
"moe.cadence.ooye.error": {
|
||||||
source: source.toLowerCase(),
|
source: source.toLowerCase(),
|
||||||
|
|
@ -158,6 +158,14 @@ async function sendError(roomID, source, type, e, payload) {
|
||||||
user_ids: ["@cadence:cadence.moe"]
|
user_ids: ["@cadence:cadence.moe"]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// Add reaction indicating that errors may be retried
|
||||||
|
await api.sendEvent(roomID, "m.reaction", {
|
||||||
|
"m.relates_to": {
|
||||||
|
rel_type: "m.annotation",
|
||||||
|
event_id: errorEventID,
|
||||||
|
key: "🔁"
|
||||||
|
}
|
||||||
|
})
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -177,6 +185,7 @@ const errorRetrySema = new Semaphore()
|
||||||
* @param {Ty.Event.Outer<Ty.Event.M_Reaction>} reactionEvent
|
* @param {Ty.Event.Outer<Ty.Event.M_Reaction>} reactionEvent
|
||||||
*/
|
*/
|
||||||
async function onRetryReactionAdd(reactionEvent) {
|
async function onRetryReactionAdd(reactionEvent) {
|
||||||
|
if (reactionEvent.sender === `@${reg.sender_localpart}:${reg.ooye.server_name}`) return // Don't respond to the bot's own indicative reaction
|
||||||
const roomID = reactionEvent.room_id
|
const roomID = reactionEvent.room_id
|
||||||
await errorRetrySema.request(async () => {
|
await errorRetrySema.request(async () => {
|
||||||
const event = await api.getEvent(roomID, reactionEvent.content["m.relates_to"]?.event_id)
|
const event = await api.getEvent(roomID, reactionEvent.content["m.relates_to"]?.event_id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue