don't set the name and topic twice
This commit is contained in:
parent
4c0aa57ba7
commit
40c3ef8e83
1 changed files with 13 additions and 5 deletions
|
@ -118,13 +118,21 @@ async function createRoom(channel, guild, spaceID, kstate) {
|
||||||
if (channel.type === DiscordTypes.ChannelType.PublicThread) threadParent = channel.parent_id
|
if (channel.type === DiscordTypes.ChannelType.PublicThread) threadParent = channel.parent_id
|
||||||
const invite = threadParent ? [] : ["@cadence:cadence.moe"] // TODO
|
const invite = threadParent ? [] : ["@cadence:cadence.moe"] // TODO
|
||||||
|
|
||||||
|
// Name and topic can be done earlier in room creation rather than in initial_state
|
||||||
|
// https://spec.matrix.org/latest/client-server-api/#creation
|
||||||
|
const name = kstate["m.room.name/"].name
|
||||||
|
delete kstate["m.room.name/"]
|
||||||
|
assert(name)
|
||||||
|
const topic = kstate["m.room.topic/"].topic
|
||||||
|
delete kstate["m.room.topic/"]
|
||||||
|
assert(topic)
|
||||||
|
|
||||||
const roomID = await postApplyPowerLevels(kstate, async kstate => {
|
const roomID = await postApplyPowerLevels(kstate, async kstate => {
|
||||||
const [convertedName, convertedTopic] = convertNameAndTopic(channel, guild, null)
|
|
||||||
const roomID = await api.createRoom({
|
const roomID = await api.createRoom({
|
||||||
name: convertedName,
|
name,
|
||||||
topic: convertedTopic,
|
topic,
|
||||||
preset: "private_chat",
|
preset: "private_chat", // This is closest to what we want, but properties from kstate override it anyway
|
||||||
visibility: "private",
|
visibility: "private", // Not shown in the room directory
|
||||||
invite,
|
invite,
|
||||||
initial_state: ks.kstateToState(kstate)
|
initial_state: ks.kstateToState(kstate)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue