Compare commits

...

2 commits

Author SHA1 Message Date
7712bc34a6 add test case for m->d too-long message 2023-08-24 00:35:35 +12:00
587267250d syncing all room power levels 2023-08-24 00:27:51 +12:00
3 changed files with 35 additions and 4 deletions

View file

@ -63,9 +63,8 @@ async function channelToKState(channel, guild) {
assert.ok(typeof spaceID === "string") assert.ok(typeof spaceID === "string")
const row = db.prepare("SELECT nick, custom_avatar FROM channel_room WHERE channel_id = ?").get(channel.id) const row = db.prepare("SELECT nick, custom_avatar FROM channel_room WHERE channel_id = ?").get(channel.id)
assert(row) const customName = row?.nick
const customName = row.nick const customAvatar = row?.custom_avatar
const customAvatar = row.custom_avatar
const [convertedName, convertedTopic] = convertNameAndTopic(channel, guild, customName) const [convertedName, convertedTopic] = convertNameAndTopic(channel, guild, customName)
const avatarEventContent = {} const avatarEventContent = {}

View file

@ -27,3 +27,31 @@ test("event2message: janky test", t => {
}] }]
) )
}) })
test("event2message: long messages are split", t => {
t.deepEqual(
eventToMessage({
content: {
body: ("a".repeat(130) + " ").repeat(19),
msgtype: "m.text"
},
event_id: "$g07oYSZFWBkxohNEfywldwgcWj1hbhDzQ1sBAKvqOOU",
origin_server_ts: 1688301929913,
room_id: "!kLRqKKUQXcibIMtOpl:cadence.moe",
sender: "@cadence:cadence.moe",
type: "m.room.message",
unsigned: {
age: 405299
}
}),
[{
username: "cadence",
content: (("a".repeat(130) + " ").repeat(15)).slice(0, -1),
avatar_url: undefined
}, {
username: "cadence",
content: (("a".repeat(130) + " ").repeat(4)).slice(0, -1),
avatar_url: undefined
}]
)
})

View file

@ -1,8 +1,12 @@
// @ts-check // @ts-check
const fs = require("fs") const fs = require("fs")
const assert = require("assert").strict
const yaml = require("js-yaml") const yaml = require("js-yaml")
/** @ts-ignore @type {import("../types").AppServiceRegistrationConfig} */ /** @ts-ignore @type {import("../types").AppServiceRegistrationConfig} */
const reg = yaml.load(fs.readFileSync("registration.yaml", "utf8")) const reg = yaml.load(fs.readFileSync("registration.yaml", "utf8"))
module.exports = reg assert(reg.ooye.max_file_size)
assert(reg.ooye.namespace_prefix)
assert(reg.ooye.server_name)
module.exports = reg