Have to join user before announcing thread
This commit is contained in:
parent
e49dc18e67
commit
0e75c23aee
1 changed files with 6 additions and 4 deletions
|
@ -8,6 +8,8 @@ const {discord, sync, db, select} = passthrough
|
|||
const threadToAnnouncement = sync.require("../converters/thread-to-announcement")
|
||||
/** @type {import("../../matrix/api")} */
|
||||
const api = sync.require("../../matrix/api")
|
||||
/** @type {import("./register-user")} */
|
||||
const registerUser = sync.require("./register-user")
|
||||
|
||||
/**
|
||||
* @param {string} parentRoomID
|
||||
|
@ -15,10 +17,10 @@ const api = sync.require("../../matrix/api")
|
|||
* @param {import("discord-api-types/v10").APIThreadChannel} 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})
|
||||
|
||||
await api.sendEvent(parentRoomID, "m.room.message", content, creatorMxid)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue