d2m: Create voice channels as call rooms
This commit is contained in:
parent
e28eac6bfa
commit
12f4103870
3 changed files with 41 additions and 0 deletions
|
|
@ -193,6 +193,16 @@ async function channelToKState(channel, guild, di) {
|
|||
// Don't overwrite room topic if the topic has been customised
|
||||
if (hasCustomTopic) delete channelKState["m.room.topic/"]
|
||||
|
||||
// Make voice channels be a Matrix voice room (MSC3417)
|
||||
if (channel.type === DiscordTypes.ChannelType.GuildVoice) {
|
||||
creationContent.type = "org.matrix.msc3417.call"
|
||||
channelKState["org.matrix.msc3401.call/"] = {
|
||||
"m.intent": "m.room",
|
||||
"m.type": "m.voice",
|
||||
"m.name": customName || channel.name
|
||||
}
|
||||
}
|
||||
|
||||
// Don't add a space parent if it's self service
|
||||
// (The person setting up self-service has already put it in their preferred space to be able to get this far.)
|
||||
const autocreate = select("guild_active", "autocreate", {guild_id: guild.id}).pluck().get()
|
||||
|
|
|
|||
|
|
@ -190,6 +190,17 @@ test("channel2room: read-only discord channel", async t => {
|
|||
t.equal(api.getCalled(), 2)
|
||||
})
|
||||
|
||||
test("channel2room: voice channel", async t => {
|
||||
const api = mockAPI(t)
|
||||
const state = kstateStripConditionals(await channelToKState(testData.channel.voice, testData.guild.general, {api}).then(x => x.channelKState))
|
||||
t.equal(state["m.room.create/"].type, "org.matrix.msc3417.call")
|
||||
t.deepEqual(state["org.matrix.msc3401.call/"], {
|
||||
"m.intent": "m.room",
|
||||
"m.name": "🍞丨[8user] Piece",
|
||||
"m.type": "m.voice"
|
||||
})
|
||||
})
|
||||
|
||||
test("convertNameAndTopic: custom name and topic", t => {
|
||||
t.deepEqual(
|
||||
_convertNameAndTopic({id: "123", name: "the-twilight-zone", topic: "Spooky stuff here. :ghost:", type: 0}, {id: "456"}, "hauntings"),
|
||||
|
|
|
|||
20
test/data.js
20
test/data.js
|
|
@ -19,6 +19,26 @@ module.exports = {
|
|||
default_thread_rate_limit_per_user: 0,
|
||||
guild_id: "112760669178241024"
|
||||
},
|
||||
voice: {
|
||||
voice_background_display: null,
|
||||
version: 1774469910848,
|
||||
user_limit: 0,
|
||||
type: 2,
|
||||
theme_color: null,
|
||||
status: null,
|
||||
rtc_region: null,
|
||||
rate_limit_per_user: 0,
|
||||
position: 0,
|
||||
permission_overwrites: [],
|
||||
parent_id: "805261291908104252",
|
||||
nsfw: false,
|
||||
name: "🍞丨[8user] Piece",
|
||||
last_message_id: "1459912691098325137",
|
||||
id: "1036840786093953084",
|
||||
flags: 0,
|
||||
bitrate: 256000,
|
||||
guild_id: "112760669178241024"
|
||||
},
|
||||
updates: {
|
||||
type: 0,
|
||||
topic: "Updates and release announcements for Out Of Your Element.",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue