m->d avoid using blockquote as reply preview
This commit is contained in:
parent
efa0171172
commit
aa263d3eb8
3 changed files with 53 additions and 5 deletions
|
@ -210,7 +210,7 @@ async function eventToMessage(event, guild, di) {
|
||||||
replyLine += `Ⓜ️**${senderName}**:`
|
replyLine += `Ⓜ️**${senderName}**:`
|
||||||
}
|
}
|
||||||
const repliedToContent = repliedToEvent.content.formatted_body || repliedToEvent.content.body
|
const repliedToContent = repliedToEvent.content.formatted_body || repliedToEvent.content.body
|
||||||
const contentPreviewChunks = chunk(repliedToContent.replace(/.*<\/mx-reply>/, "").replace(/(?:\n|<br>)+/g, " ").replace(/<[^>]+>/g, ""), 50)
|
const contentPreviewChunks = chunk(repliedToContent.replace(/.*<\/mx-reply>/, "").replace(/.*?<\/blockquote>/, "").replace(/(?:\n|<br>)+/g, " ").replace(/<[^>]+>/g, ""), 50)
|
||||||
const contentPreview = contentPreviewChunks.length > 1 ? contentPreviewChunks[0] + "..." : contentPreviewChunks[0]
|
const contentPreview = contentPreviewChunks.length > 1 ? contentPreviewChunks[0] + "..." : contentPreviewChunks[0]
|
||||||
replyLine = `> ${replyLine}\n> ${contentPreview}\n`
|
replyLine = `> ${replyLine}\n> ${contentPreview}\n`
|
||||||
})()
|
})()
|
||||||
|
|
|
@ -535,6 +535,55 @@ test("event2message: rich reply to a sim user", async t => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("event2message: should avoid using blockquote contents as reply preview in rich reply to a sim user", async t => {
|
||||||
|
t.deepEqual(
|
||||||
|
await eventToMessage({
|
||||||
|
type: "m.room.message",
|
||||||
|
sender: "@cadence:cadence.moe",
|
||||||
|
content: {
|
||||||
|
msgtype: "m.text",
|
||||||
|
body: "> <@_ooye_kyuugryphon:cadence.moe> > well, you said this, so...\n> \n> that can't be true! there's no way :o\n\nI agree!",
|
||||||
|
format: "org.matrix.custom.html",
|
||||||
|
formatted_body: "<mx-reply><blockquote><a href=\"https://matrix.to/#/!fGgIymcYWOqjbSRUdV:cadence.moe/$Fxy8SMoJuTduwReVkHZ1uHif9EuvNx36Hg79cltiA04?via=cadence.moe\">In reply to</a> <a href=\"https://matrix.to/#/@_ooye_kyuugryphon:cadence.moe\">@_ooye_kyuugryphon:cadence.moe</a><br><blockquote>well, you said this, so...<br /></blockquote><br />that can't be true! there's no way :o</blockquote></mx-reply>I agree!",
|
||||||
|
"m.relates_to": {
|
||||||
|
"m.in_reply_to": {
|
||||||
|
event_id: "$Fxy8SMoJuTduwReVkHZ1uHif9EuvNx36Hg79cltiA04"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
event_id: "$BpGx8_vqHyN6UQDARPDU51ftrlRBhleutRSgpAJJ--g",
|
||||||
|
room_id: "!fGgIymcYWOqjbSRUdV:cadence.moe"
|
||||||
|
}, data.guild.general, {
|
||||||
|
api: {
|
||||||
|
getEvent: mockGetEvent(t, "!fGgIymcYWOqjbSRUdV:cadence.moe", "$Fxy8SMoJuTduwReVkHZ1uHif9EuvNx36Hg79cltiA04", {
|
||||||
|
"type": "m.room.message",
|
||||||
|
"sender": "@_ooye_kyuugryphon:cadence.moe",
|
||||||
|
"content": {
|
||||||
|
"m.mentions": {},
|
||||||
|
"msgtype": "m.text",
|
||||||
|
"body": "> well, you said this, so...\n\nthat can't be true! there's no way :o",
|
||||||
|
"format": "org.matrix.custom.html",
|
||||||
|
"formatted_body": "<blockquote>well, you said this, so...<br></blockquote><br>that can't be true! there's no way :o"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
messagesToDelete: [],
|
||||||
|
messagesToEdit: [],
|
||||||
|
messagesToSend: [{
|
||||||
|
username: "cadence [they]",
|
||||||
|
content: "> <:L1:1144820033948762203><:L2:1144820084079087647>https://discord.com/channels/112760669178241024/687028734322147344/1144865310588014633 <@111604486476181504>:"
|
||||||
|
+ "\n> that can't be true! there's no way :o"
|
||||||
|
+ "\nI agree!",
|
||||||
|
avatar_url: "https://matrix.cadence.moe/_matrix/media/r0/download/cadence.moe/azCAhThKTojXSZJRoWwZmhvU"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
test("event2message: editing a rich reply to a sim user", async t => {
|
test("event2message: editing a rich reply to a sim user", async t => {
|
||||||
const eventsFetched = []
|
const eventsFetched = []
|
||||||
t.deepEqual(
|
t.deepEqual(
|
||||||
|
|
7
notes.md
7
notes.md
|
@ -2,14 +2,13 @@
|
||||||
|
|
||||||
## Known issues
|
## Known issues
|
||||||
|
|
||||||
- m->d attachments do not work
|
|
||||||
- m->d replying to a message that used a blockquote should avoid using the blockquote contents as the preview
|
|
||||||
- d->m emojis do not work at all (inline chat, single emoji size, reactions, bridged state)
|
- d->m emojis do not work at all (inline chat, single emoji size, reactions, bridged state)
|
||||||
|
- d->m embeds
|
||||||
- m->d code blocks have slightly too much spacing
|
- m->d code blocks have slightly too much spacing
|
||||||
- m->d some reactions don't work because of the variation selector
|
|
||||||
- d->m check whether I implemented deletions
|
- d->m check whether I implemented deletions
|
||||||
- m->d deletions
|
- m->d deletions
|
||||||
- rooms will be set up even if the bridge does not have permission for them, then break when it restarts and tries to reach messages
|
- removing reactions
|
||||||
|
- rooms will be set up even if the bridge does not have permission for the channels, which breaks when it restarts and tries to fetch messages
|
||||||
- test private threads as part of this
|
- test private threads as part of this
|
||||||
- solution part 1: calculate the permissions to see if the bot should be able to do stuff
|
- solution part 1: calculate the permissions to see if the bot should be able to do stuff
|
||||||
- solution part 2: attempt a get messages request anyway before bridging a new room, just to make sure!
|
- solution part 2: attempt a get messages request anyway before bridging a new room, just to make sure!
|
||||||
|
|
Loading…
Reference in a new issue