1
0
Fork 0

Have to join user before announcing thread

This commit is contained in:
Cadence Ember 2024-01-20 23:45:47 +13:00
parent e49dc18e67
commit 0e75c23aee

View file

@ -8,6 +8,8 @@ const {discord, sync, db, select} = passthrough
const threadToAnnouncement = sync.require("../converters/thread-to-announcement") const threadToAnnouncement = sync.require("../converters/thread-to-announcement")
/** @type {import("../../matrix/api")} */ /** @type {import("../../matrix/api")} */
const api = sync.require("../../matrix/api") const api = sync.require("../../matrix/api")
/** @type {import("./register-user")} */
const registerUser = sync.require("./register-user")
/** /**
* @param {string} parentRoomID * @param {string} parentRoomID
@ -15,10 +17,10 @@ const api = sync.require("../../matrix/api")
* @param {import("discord-api-types/v10").APIThreadChannel} thread * @param {import("discord-api-types/v10").APIThreadChannel} thread
*/ */
async function announceThread(parentRoomID, threadRoomID, thread) { async function announceThread(parentRoomID, threadRoomID, thread) {
const creatorMxid = select("sim", "mxid", {user_id: thread.owner_id}).pluck().get() assert(thread.owner_id)
// @ts-ignore
const creatorMxid = await registerUser.ensureSimJoined({id: thread.owner_id}, parentRoomID)
const content = await threadToAnnouncement.threadToAnnouncement(parentRoomID, threadRoomID, creatorMxid, thread, {api}) const content = await threadToAnnouncement.threadToAnnouncement(parentRoomID, threadRoomID, creatorMxid, thread, {api})
await api.sendEvent(parentRoomID, "m.room.message", content, creatorMxid) await api.sendEvent(parentRoomID, "m.room.message", content, creatorMxid)
} }