fix a variety of bugs that snuck in

This commit is contained in:
Cadence Ember 2023-06-28 23:38:58 +12:00
parent 512f61422d
commit 584f19a011
6 changed files with 13 additions and 11 deletions

View file

@ -58,7 +58,7 @@ async function channelToKState(channel, guild) {
"m.room.join_rules/": { "m.room.join_rules/": {
join_rule: "restricted", join_rule: "restricted",
allow: [{ allow: [{
type: "m.room.membership", type: "m.room_membership",
room_id: spaceID room_id: spaceID
}] }]
} }
@ -179,8 +179,10 @@ async function createAllForGuild(guildID) {
const channelIDs = discord.guildChannelMap.get(guildID) const channelIDs = discord.guildChannelMap.get(guildID)
assert.ok(channelIDs) assert.ok(channelIDs)
for (const channelID of channelIDs) { for (const channelID of channelIDs) {
if (discord.channels.get(channelID)?.type === DiscordTypes.ChannelType.GuildText) { // TODO: guild sync thread channels and such. maybe make a helper function to check if a given channel is syncable?
await syncRoom(channelID).then(r => console.log(`synced ${channelID}:`, r)) await syncRoom(channelID).then(r => console.log(`synced ${channelID}:`, r))
} }
}
} }
module.exports.createRoom = createRoom module.exports.createRoom = createRoom

View file

@ -15,14 +15,14 @@ const createRoom = sync.require("../actions/create-room")
/** /**
* @param {import("discord-api-types/v10").GatewayMessageCreateDispatchData} message * @param {import("discord-api-types/v10").GatewayMessageCreateDispatchData} message
* @param {import("discord-api-types/v10").APIGuild} guild
*/ */
async function sendMessage(message) { async function sendMessage(message, guild) {
assert.ok(message.member)
const roomID = await createRoom.ensureRoom(message.channel_id) const roomID = await createRoom.ensureRoom(message.channel_id)
let senderMxid = null let senderMxid = null
if (!message.webhook_id) { if (!message.webhook_id) {
assert(message.member)
senderMxid = await registerUser.ensureSimJoined(message.author, roomID) senderMxid = await registerUser.ensureSimJoined(message.author, roomID)
await registerUser.syncUser(message.author, message.member, message.guild_id, roomID) await registerUser.syncUser(message.author, message.member, message.guild_id, roomID)
} }

View file

@ -24,7 +24,7 @@ module.exports = {
* @param {import("discord-api-types/v10").GatewayMessageReactionAddDispatchData} data * @param {import("discord-api-types/v10").GatewayMessageReactionAddDispatchData} data
*/ */
onReactionAdd(client, data) { onReactionAdd(client, data) {
if (data.emoji.id !== null) return // TOOD: image emoji reactions if (data.emoji.id !== null) return // TODO: image emoji reactions
console.log(data) console.log(data)
addReaction.addReaction(data) addReaction.addReaction(data)
} }

View file

@ -78,7 +78,7 @@ function getAllState(roomID) {
async function sendState(roomID, type, stateKey, content, mxid) { async function sendState(roomID, type, stateKey, content, mxid) {
console.log(`[api] state: ${roomID}: ${type}/${stateKey}`) console.log(`[api] state: ${roomID}: ${type}/${stateKey}`)
assert.ok(type) assert.ok(type)
assert.ok(stateKey) assert.ok(typeof stateKey === "string")
/** @type {import("../types").R.EventSent} */ /** @type {import("../types").R.EventSent} */
const root = await mreq.mreq("PUT", path(`/client/v3/rooms/${roomID}/state/${type}/${stateKey}`, mxid), content) const root = await mreq.mreq("PUT", path(`/client/v3/rooms/${roomID}/state/${type}/${stateKey}`, mxid), content)
return root.event_id return root.event_id

6
package-lock.json generated
View file

@ -478,9 +478,9 @@
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
}, },
"node_modules/better-sqlite3": { "node_modules/better-sqlite3": {
"version": "8.3.0", "version": "8.4.0",
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-8.3.0.tgz", "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-8.4.0.tgz",
"integrity": "sha512-JTmvBZL/JLTc+3Msbvq6gK6elbU9/wVMqiudplHrVJpr7sVMR9KJrNhZAbW+RhXKlpMcuEhYkdcHa3TXKNXQ1w==", "integrity": "sha512-NmsNW1CQvqMszu/CFAJ3pLct6NEFlNfuGM6vw72KHkjOD1UDnL96XNN1BMQc1hiHo8vE2GbOWQYIpZ+YM5wrZw==",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"bindings": "^1.5.0", "bindings": "^1.5.0",

View file

@ -33,7 +33,7 @@ module.exports = {
"m.room.join_rules/": { "m.room.join_rules/": {
join_rule: "restricted", join_rule: "restricted",
allow: [{ allow: [{
type: "m.room.membership", type: "m.room_membership",
room_id: "!jjWAGMeQdNrVZSSfvz:cadence.moe" room_id: "!jjWAGMeQdNrVZSSfvz:cadence.moe"
}] }]
}, },