send sim messages to the proper rooms

This commit is contained in:
Cadence Ember 2023-05-09 15:29:46 +12:00
parent 7526d63690
commit da6603d258
10 changed files with 38 additions and 10 deletions

View file

@ -11,11 +11,12 @@ const reg = sync.require("./read-registration.js")
const baseUrl = "https://matrix.cadence.moe/_matrix"
class MatrixServerError extends Error {
constructor(data) {
constructor(data, opts) {
super(data.error || data.errcode)
this.data = data
/** @type {string} */
this.errcode = data.errcode
this.opts = opts
}
}
@ -38,7 +39,7 @@ async function mreq(method, url, body, extra = {}) {
const res = await fetch(baseUrl + url, opts)
const root = await res.json()
if (!res.ok || root.errcode) throw new MatrixServerError(root)
if (!res.ok || root.errcode) throw new MatrixServerError(root, opts)
return root
}