matrix/kstate: best effort

This commit is contained in:
2026-01-21 13:32:11 +09:00
parent d8fdb27fee
commit 04d7872acb

View File

@@ -12,6 +12,8 @@ const file = sync.require("./file")
const api = sync.require("./api")
/** @type {import("./utils")} */
const utils = sync.require("./utils")
/** @type {import("./utils")} */
const mreq = sync.require("./mreq")
/** Mutates the input. Not recursive - can only include or exclude entire state events. */
function kstateStripConditionals(kstate) {
@@ -149,8 +151,16 @@ async function roomToKState(roomID, limitToEvents) {
} else {
const root = []
await Promise.all(limitToEvents.map(async ([type, key]) => {
const outer = await api.getStateEventOuter(roomID, type, key)
root.push(outer)
try {
const outer = await api.getStateEventOuter(roomID, type, key)
root.push(outer)
} catch (e) {
if (e instanceof mreq.MatrixServerError) {
console.warn(`Unable to fetch all events ¯\\_(ツ)_/¯\nCaught exception: ${e}`)
} else {
throw e
}
}
}))
return stateToKState(root)
}