[WIP] threads. #74
2 changed files with 9 additions and 12 deletions
RIP Ellie Mode; fck u Commet
The whole reason this woke branch up again, is that Cadence said she wants to use Matrix threads for discoverability of Discord threads. So RIP Ellie Mode (the one that eradicates threads fully).
commit
e1b512bf09
|
|
@ -17,7 +17,6 @@ const userRegex = reg.namespaces.users.map(u => new RegExp(u.regex))
|
||||||
*/
|
*/
|
||||||
async function threadToAnnouncement(parentRoomID, threadRoomID, creatorMxid, thread, di) {
|
async function threadToAnnouncement(parentRoomID, threadRoomID, creatorMxid, thread, di) {
|
||||||
const branchedFromEventID = select("event_message", "event_id", {message_id: thread.id}).pluck().get()
|
const branchedFromEventID = select("event_message", "event_id", {message_id: thread.id}).pluck().get()
|
||||||
const ellieMode = false //See: https://matrix.to/#/!PuFmbgRjaJsAZTdSja:cadence.moe?via=cadence.moe&via=chat.untitledzero.dev&via=guziohub.ovh - TL;DR: Ellie's idea was to not leave any sign of Matrix threads existing, while Guzio preferred that the link to created thread-rooms stay within the Matrix thread (to better approximate Discord UI on compatible clients). This settings-option-but-not-really (it's not meant to be changed by end users unless they know what they're doing) would let Cadence switch between both approaches over some time period, to test the feeling of both, and finally land on whichever UX she prefers best. TODO: Remove this toggle (and make the chosen solution permanent) once those tests conclude.
|
|
||||||
|
|
||||||
/** @type {{"m.mentions"?: any, "m.relates_to"?: {event_id?: string, is_falling_back?: boolean, "m.in_reply_to"?: {event_id: string}, rel_type?: "m.replace"|"m.thread"}}} */
|
/** @type {{"m.mentions"?: any, "m.relates_to"?: {event_id?: string, is_falling_back?: boolean, "m.in_reply_to"?: {event_id: string}, rel_type?: "m.replace"|"m.thread"}}} */
|
||||||
const context = {}
|
const context = {}
|
||||||
|
|
@ -25,18 +24,16 @@ async function threadToAnnouncement(parentRoomID, threadRoomID, creatorMxid, thr
|
||||||
if (branchedFromEventID) {
|
if (branchedFromEventID) {
|
||||||
// Need to figure out who sent that event...
|
// Need to figure out who sent that event...
|
||||||
const event = await di.api.getEvent(parentRoomID, branchedFromEventID)
|
const event = await di.api.getEvent(parentRoomID, branchedFromEventID)
|
||||||
suffix = "\n[Note: You really should move the conversation to that room, rather than continuing to reply via a Matrix thread. Any messages sent in threads will be DELETED and instead moved to that room by the bot, which makes it the author and strips you from control (edits/deletions) over your own message!]"
|
suffix = "\n[ YOU MUST continue the conversation in that thread-room, rather than in this Matrix thread, even if your client supports MX threads. Any messages sent in MX threads ARE !DELETED! and copied to thread-rooms, which makes OOYE the author, and strips you from edit/delete rights! ]"
|
||||||
context["m.relates_to"] = {"m.in_reply_to": {event_id: event.event_id}}
|
context["m.relates_to"] = {"m.in_reply_to": {event_id: event.event_id}}
|
||||||
if (event.sender && !userRegex.some(rx => event.sender.match(rx))) context["m.mentions"] = {user_ids: [event.sender]}
|
if (event.sender && !userRegex.some(rx => event.sender.match(rx))) context["m.mentions"] = {user_ids: [event.sender]}
|
||||||
if (!ellieMode) {
|
//...And actually branch from that event
|
||||||
//...And actually branch from that event (if configured to do so)
|
|
||||||
suffix = "\n[Note: You really should continue the conversation in that room, rather than in this Matrix thread. Any messages sent here will be DELETED and instead moved there by the bot, which makes it the author and strips you from control (edits/deletions) over your own message!]"
|
|
||||||
context["m.relates_to"] = {"m.in_reply_to": {event_id: event.event_id}, is_falling_back:false, event_id: event.event_id, rel_type: "m.thread"}
|
context["m.relates_to"] = {"m.in_reply_to": {event_id: event.event_id}, is_falling_back:false, event_id: event.event_id, rel_type: "m.thread"}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const msgtype = creatorMxid ? "m.emote" : "m.text"
|
//TODO: Wait until certain clients (*cough* Commet *cough*) figure out how to render an m.emote in a thread, and then simplify this to creatorMxid ? "m.emote" : "m.text" and creatorMxid ? "started a thread called" : "New thread started:"
|
||||||
const template = creatorMxid ? "started a thread called" : "New thread started:"
|
const msgtype = creatorMxid && !branchedFromEventID ? "m.emote" : "m.text"
|
||||||
|
const template = creatorMxid ? `${branchedFromEventID ? `${creatorMxid} ` : ""}started a thread called` : "New thread started:"
|
||||||
const via = await mxUtils.getViaServersQuery(threadRoomID, di.api)
|
const via = await mxUtils.getViaServersQuery(threadRoomID, di.api)
|
||||||
let body = `${template} \"${thread.name}\" in room: https://matrix.to/#/${threadRoomID}?${via.toString()}${suffix}`
|
let body = `${template} \"${thread.name}\" in room: https://matrix.to/#/${threadRoomID}?${via.toString()}${suffix}`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ const validNonce = new LRUCache({max: 200})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TYPING = Channels on which Discord messages can be sent. They should be bridgeable to anything other than an m.space (because if it did end up as a space, no one would be able to actually see the text messages sent there).
|
* TYPING = Channels on which Discord messages can be sent. They should be bridgeable to anything other than an m.space (because if it did end up as a space, no one would be able to actually see the text messages sent there).
|
||||||
* SPACE = Channels on which Discord messages cannot be received. They should be bridgeable to m.space only (because not only does m.space make sending messages impossible on any sane client (thus preventing Discord-caused errors), but it also just-so-happens that both currently-existing message-unsupporting channel types (Categories and School hubs) are sort of "indexes", which fits nicely to m.space).
|
* SPACE = Channels on which Discord messages cannot be sent. They should be bridgeable to m.space only (because not only does m.space make sending messages impossible on any sane client (thus preventing Discord-caused errors), but it also just-so-happens that both currently-existing message-unsupporting channel types (Categories and School hubs) are sort of "indexes", which fits nicely to m.space).
|
||||||
* MIXED = Forum-like channels. They can be bridged to both m.space and anything other than an m.space - hence the name.
|
* MIXED = Forum-like channels. They can be bridged to both m.space and anything other than an m.space - hence the name.
|
||||||
* @type {Map<DiscordTypes.ChannelType, {type: "TYPING"|"MIXED"|"SPACE", humanName:string, unsupported?: string}>}*/
|
* @type {Map<DiscordTypes.ChannelType, {type: "TYPING"|"MIXED"|"SPACE", humanName:string, unsupported?: string}>}*/
|
||||||
const linkRules = new Map([
|
const linkRules = new Map([
|
||||||
|
|
@ -66,13 +66,13 @@ const linkRules = new Map([
|
||||||
[1, {type: "TYPING", humanName:"Normal DMs", unsupported: "OOYE won't support DMs until a good way of doing it can be figured out. Please see https://gitdab.com/cadence/out-of-your-element#caveats for more."}],
|
[1, {type: "TYPING", humanName:"Normal DMs", unsupported: "OOYE won't support DMs until a good way of doing it can be figured out. Please see https://gitdab.com/cadence/out-of-your-element#caveats for more."}],
|
||||||
[2, {type: "TYPING", humanName:"Normal VCs"}],
|
[2, {type: "TYPING", humanName:"Normal VCs"}],
|
||||||
[3, {type: "TYPING", humanName:"Group DMs", unsupported: "OOYE won't support DMs until a good way of doing it can be figured out. Please see https://gitdab.com/cadence/out-of-your-element#caveats for more."}],
|
[3, {type: "TYPING", humanName:"Group DMs", unsupported: "OOYE won't support DMs until a good way of doing it can be figured out. Please see https://gitdab.com/cadence/out-of-your-element#caveats for more."}],
|
||||||
[4, {type: "SPACE", humanName:"Categories", unsupported: "There is no concept of categories on Matrix."}], //...at least officially. In practice, some clients will render sub-spaces as categories. TODO: Bridge categories to sub-spaces.
|
[4, {type: "SPACE", humanName:"Categories", unsupported: "There is no concept of categories on Matrix."}], //...at least officially. In practice, some clients will render sub-spaces as categories. TODO: Research Cadence's stance on bridging categories to sub-spaces.
|
||||||
[5, {type: "TYPING", humanName:"Announcement text channels"}],
|
[5, {type: "TYPING", humanName:"Announcement text channels"}],
|
||||||
[10, {type: "TYPING", humanName:"Announcement threads"}],
|
[10, {type: "TYPING", humanName:"Announcement threads"}],
|
||||||
[11, {type: "TYPING", humanName:"Normal threads"}],
|
[11, {type: "TYPING", humanName:"Normal threads"}],
|
||||||
[12, {type: "TYPING", humanName:"Private threads"}],
|
[12, {type: "TYPING", humanName:"Private threads"}],
|
||||||
[13, {type: "TYPING", humanName:"Stage VCs"}],
|
[13, {type: "TYPING", humanName:"Stage VCs"}],
|
||||||
[14, {type: "SPACE", humanName:"School hubs", unsupported: "Bots cannot be members of school hubs. How in the sweet hell did you manage to put OOYE on one, anyway??? ~~Emma, please stop breaking Discord API in cursed ways again.~~"}],
|
[14, {type: "SPACE", humanName:"School hubs", unsupported: "Bots cannot be members of school hubs. With that said, how in the sweet hell did you manage to put OOYE on one???"}],
|
||||||
[15, {type: "MIXED", humanName:"Normal forums"}],
|
[15, {type: "MIXED", humanName:"Normal forums"}],
|
||||||
[16, {type: "MIXED", humanName:"Media forums"}],
|
[16, {type: "MIXED", humanName:"Media forums"}],
|
||||||
])
|
])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue