WIP: feature: threads'n'forums #74
1 changed files with 20 additions and 9 deletions
|
|
@ -78,7 +78,7 @@ async function bridgeThread(event) {
|
|||
|
||||
/**
|
||||
* @param {Ty.Event.Outer_M_Room_Message | Ty.Event.Outer_M_Room_Message_File} event
|
||||
* @returns {Promise<boolean>} true if a forum-thread-room was created
|
||||
* @returns {Promise<boolean>} whether a forum-thread-room was created
|
||||
*/
|
||||
async function handleForums(event) {
|
||||
if (event.content.body === "/thread") return false; //Let the help be shown normally
|
||||
|
|
@ -91,14 +91,25 @@ async function handleForums(event) {
|
|||
|
||||
const name = computeName(event)
|
||||
let resetNeeded = false
|
||||
try {
|
||||
if(channel.flags && channel.flags & DiscordTypes.ChannelFlags.RequireTag){
|
||||
await discord.snow.channel.updateChannel(channelID, {flags:(channel.flags^DiscordTypes.ChannelFlags.RequireTag)}, "Temporary flag reset, to override tagging requirements for Matrix threads that can't be tagged.")
|
||||
await discord.snow.channel.updateChannel(channelID, {flags:(channel.flags^DiscordTypes.ChannelFlags.RequireTag)}, "Temporary override of tagging requirements because Matrix threads that can't be tagged yet.")
|
||||
resetNeeded = true
|
||||
}
|
||||
//@ts-ignore the presence of message:{} and the absence of type:11 - that's intended for threads in Forum channels (*and no, createThreadWithMessage wouldn't work here, either - that one takes an ALREADY EXISTING message ID, whereas this needs a new message)
|
||||
await discord.snow.channel.createThreadWithoutMessage(channelID, {name: name.name, message:{content:"heyy~"}})
|
||||
if (!name.truncated) api.redactEvent(event.room_id, event.event_id) //Don't destroy people's texts - only remove if no truncation is guaranteed.
|
||||
if (resetNeeded) discord.snow.channel.updateChannel(channelID, channel, "Restoring flags to their original state.")
|
||||
if (resetNeeded) discord.snow.channel.updateChannel(channelID, {flags:channel.flags}, "Restoring flags to their original state.")
|
||||
}
|
||||
catch (e){
|
||||
if (e.message?.includes("50013")){
|
||||
api.sendEvent(event.room_id, "m.room.message", {
|
||||
body: "You can't create threads in this forum right now! This forum is configured to require tags on post (Matrix users can't yet use tags yet), and OOYE doesn't have the permission to edit this channel on Discord (needed to bypass the requirement of tags). Unless this is intentional (see room description - the admins may have left a note), please ask someone on the Discord side to either grant OOYE the necessary permissions, or to remove tagging requirements.",
|
||||
msgtype: "m.text"
|
||||
})
|
||||
}
|
||||
else throw e
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue