Properly hide embeds for links in reply previews
This commit is contained in:
@@ -370,6 +370,7 @@ async function messageToEvent(message, guild, options = {}, di) {
|
|||||||
return `https://matrix.to/#/${oldestRow.room_id}/${event_id}?${via}`
|
return `https://matrix.to/#/${oldestRow.room_id}/${event_id}?${via}`
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// M_NOT_FOUND: Unable to find event from <ts> in direction Direction.FORWARDS
|
// M_NOT_FOUND: Unable to find event from <ts> in direction Direction.FORWARDS
|
||||||
|
// not supported in Conduit and descendants
|
||||||
return `[unknown event, timestamp resolution failed, in room: https://matrix.to/#/${oldestRow.room_id}?${via}]`
|
return `[unknown event, timestamp resolution failed, in room: https://matrix.to/#/${oldestRow.room_id}?${via}]`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -739,11 +739,11 @@ async function eventToMessage(event, guild, di) {
|
|||||||
return convertEmoji(mxcUrlMatch?.[1], titleTextMatch?.[1], false, false)
|
return convertEmoji(mxcUrlMatch?.[1], titleTextMatch?.[1], false, false)
|
||||||
})
|
})
|
||||||
repliedToContent = repliedToContent.replace(/<[^:>][^>]*>/g, "") // Completely strip all HTML tags and formatting.
|
repliedToContent = repliedToContent.replace(/<[^:>][^>]*>/g, "") // Completely strip all HTML tags and formatting.
|
||||||
repliedToContent = repliedToContent.replace(/\bhttps?:\/\/[^ )]*/g, "<$&>")
|
|
||||||
repliedToContent = entities.decodeHTML5Strict(repliedToContent) // Remove entities like & "
|
repliedToContent = entities.decodeHTML5Strict(repliedToContent) // Remove entities like & "
|
||||||
const contentPreviewChunks = chunk(repliedToContent, 50)
|
const contentPreviewChunks = chunk(repliedToContent, 50)
|
||||||
if (contentPreviewChunks.length) {
|
if (contentPreviewChunks.length) {
|
||||||
contentPreview = ": " + contentPreviewChunks[0]
|
contentPreview = ": " + contentPreviewChunks[0]
|
||||||
|
contentPreview = contentPreview.replace(/\bhttps?:\/\/[^ )]*/g, "<$&>")
|
||||||
if (contentPreviewChunks.length > 1) contentPreview = contentPreview.replace(/[,.']$/, "") + "..."
|
if (contentPreviewChunks.length > 1) contentPreview = contentPreview.replace(/[,.']$/, "") + "..."
|
||||||
} else {
|
} else {
|
||||||
contentPreview = ""
|
contentPreview = ""
|
||||||
|
|||||||
Vendored
+2
@@ -221,6 +221,7 @@ export namespace Event {
|
|||||||
filename?: string
|
filename?: string
|
||||||
url: string
|
url: string
|
||||||
info?: any
|
info?: any
|
||||||
|
"page.codeberg.everypizza.msc4193.spoiler"?: boolean
|
||||||
"m.relates_to"?: {
|
"m.relates_to"?: {
|
||||||
"m.in_reply_to": {
|
"m.in_reply_to": {
|
||||||
event_id: string
|
event_id: string
|
||||||
@@ -238,6 +239,7 @@ export namespace Event {
|
|||||||
format?: "org.matrix.custom.html"
|
format?: "org.matrix.custom.html"
|
||||||
formatted_body?: string
|
formatted_body?: string
|
||||||
filename?: string
|
filename?: string
|
||||||
|
"page.codeberg.everypizza.msc4193.spoiler"?: boolean
|
||||||
file: {
|
file: {
|
||||||
url: string
|
url: string
|
||||||
iv: string
|
iv: string
|
||||||
|
|||||||
Reference in New Issue
Block a user