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}`
|
||||
} catch (e) {
|
||||
// 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}]`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -739,11 +739,11 @@ async function eventToMessage(event, guild, di) {
|
||||
return convertEmoji(mxcUrlMatch?.[1], titleTextMatch?.[1], false, false)
|
||||
})
|
||||
repliedToContent = repliedToContent.replace(/<[^:>][^>]*>/g, "") // Completely strip all HTML tags and formatting.
|
||||
repliedToContent = repliedToContent.replace(/\bhttps?:\/\/[^ )]*/g, "<$&>")
|
||||
repliedToContent = entities.decodeHTML5Strict(repliedToContent) // Remove entities like & "
|
||||
const contentPreviewChunks = chunk(repliedToContent, 50)
|
||||
if (contentPreviewChunks.length) {
|
||||
contentPreview = ": " + contentPreviewChunks[0]
|
||||
contentPreview = contentPreview.replace(/\bhttps?:\/\/[^ )]*/g, "<$&>")
|
||||
if (contentPreviewChunks.length > 1) contentPreview = contentPreview.replace(/[,.']$/, "") + "..."
|
||||
} else {
|
||||
contentPreview = ""
|
||||
|
||||
2
src/types.d.ts
vendored
2
src/types.d.ts
vendored
@@ -221,6 +221,7 @@ export namespace Event {
|
||||
filename?: string
|
||||
url: string
|
||||
info?: any
|
||||
"page.codeberg.everypizza.msc4193.spoiler"?: boolean
|
||||
"m.relates_to"?: {
|
||||
"m.in_reply_to": {
|
||||
event_id: string
|
||||
@@ -238,6 +239,7 @@ export namespace Event {
|
||||
format?: "org.matrix.custom.html"
|
||||
formatted_body?: string
|
||||
filename?: string
|
||||
"page.codeberg.everypizza.msc4193.spoiler"?: boolean
|
||||
file: {
|
||||
url: string
|
||||
iv: string
|
||||
|
||||
Reference in New Issue
Block a user