diff --git a/d2m/actions/create-room.js b/d2m/actions/create-room.js index 96a9671..c4baa2d 100644 --- a/d2m/actions/create-room.js +++ b/d2m/actions/create-room.js @@ -58,7 +58,7 @@ async function channelToKState(channel, guild) { "m.room.join_rules/": { join_rule: "restricted", allow: [{ - type: "m.room.membership", + type: "m.room_membership", room_id: spaceID }] } @@ -179,7 +179,9 @@ async function createAllForGuild(guildID) { const channelIDs = discord.guildChannelMap.get(guildID) assert.ok(channelIDs) for (const channelID of channelIDs) { - await syncRoom(channelID).then(r => console.log(`synced ${channelID}:`, r)) + 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)) + } } } diff --git a/d2m/actions/send-message.js b/d2m/actions/send-message.js index 738c59a..897f7c0 100644 --- a/d2m/actions/send-message.js +++ b/d2m/actions/send-message.js @@ -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").APIGuild} guild */ -async function sendMessage(message) { - assert.ok(message.member) - +async function sendMessage(message, guild) { const roomID = await createRoom.ensureRoom(message.channel_id) let senderMxid = null if (!message.webhook_id) { + assert(message.member) senderMxid = await registerUser.ensureSimJoined(message.author, roomID) await registerUser.syncUser(message.author, message.member, message.guild_id, roomID) } diff --git a/d2m/event-dispatcher.js b/d2m/event-dispatcher.js index eeee451..baf19a8 100644 --- a/d2m/event-dispatcher.js +++ b/d2m/event-dispatcher.js @@ -24,7 +24,7 @@ module.exports = { * @param {import("discord-api-types/v10").GatewayMessageReactionAddDispatchData} 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) addReaction.addReaction(data) } diff --git a/matrix/api.js b/matrix/api.js index 846ea64..3ec014d 100644 --- a/matrix/api.js +++ b/matrix/api.js @@ -78,7 +78,7 @@ function getAllState(roomID) { async function sendState(roomID, type, stateKey, content, mxid) { console.log(`[api] state: ${roomID}: ${type}/${stateKey}`) assert.ok(type) - assert.ok(stateKey) + assert.ok(typeof stateKey === "string") /** @type {import("../types").R.EventSent} */ const root = await mreq.mreq("PUT", path(`/client/v3/rooms/${roomID}/state/${type}/${stateKey}`, mxid), content) return root.event_id diff --git a/package-lock.json b/package-lock.json index 9556331..224e232 100644 --- a/package-lock.json +++ b/package-lock.json @@ -478,9 +478,9 @@ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, "node_modules/better-sqlite3": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-8.3.0.tgz", - "integrity": "sha512-JTmvBZL/JLTc+3Msbvq6gK6elbU9/wVMqiudplHrVJpr7sVMR9KJrNhZAbW+RhXKlpMcuEhYkdcHa3TXKNXQ1w==", + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-8.4.0.tgz", + "integrity": "sha512-NmsNW1CQvqMszu/CFAJ3pLct6NEFlNfuGM6vw72KHkjOD1UDnL96XNN1BMQc1hiHo8vE2GbOWQYIpZ+YM5wrZw==", "hasInstallScript": true, "dependencies": { "bindings": "^1.5.0", diff --git a/test/data.js b/test/data.js index 9704c8d..6a65b5f 100644 --- a/test/data.js +++ b/test/data.js @@ -33,7 +33,7 @@ module.exports = { "m.room.join_rules/": { join_rule: "restricted", allow: [{ - type: "m.room.membership", + type: "m.room_membership", room_id: "!jjWAGMeQdNrVZSSfvz:cadence.moe" }] },