Support attachment spoiler flag
This commit is contained in:
Generated
+3
-3
@@ -1518,9 +1518,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/discord-api-types": {
|
"node_modules/discord-api-types": {
|
||||||
"version": "0.38.52",
|
"version": "0.38.53",
|
||||||
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.52.tgz",
|
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.53.tgz",
|
||||||
"integrity": "sha512-uwe9EKfbjsmgWc2fdFjvDbj+dQqx3lp7wqDCmIha0jInuU+xeQjkCK9tMMn+p7RXfdVQORCInq4cD3U2ymDmyg==",
|
"integrity": "sha512-HL1zz/UuZ+bbJjA/X8Kbxx9gk8v9rJAbTeWRNYKmIdjwJ7EovjlHgoJTxcLpATfNJ+AonOtMdy3Y5MVIJAAd/A==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"scripts/actions/documentation"
|
"scripts/actions/documentation"
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ const embedTitleParser = markdown.markdownEngine.parserFor({
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {{room?: boolean, user_ids?: string[]}} mentions
|
* @param {{room?: boolean, user_ids?: string[]}} mentions
|
||||||
* @param {Omit<DiscordTypes.APIAttachment, "id" | "proxy_url" | "flags">} attachment
|
* @param {Omit<DiscordTypes.APIAttachment, "id" | "proxy_url">} attachment
|
||||||
* @param {boolean} [alwaysLink]
|
* @param {boolean} [alwaysLink]
|
||||||
*/
|
*/
|
||||||
async function attachmentToEvent(mentions, attachment, alwaysLink) {
|
async function attachmentToEvent(mentions, attachment, alwaysLink) {
|
||||||
@@ -122,7 +122,7 @@ async function attachmentToEvent(mentions, attachment, alwaysLink) {
|
|||||||
: attachment.content_type?.startsWith("audio/") ? "🎶"
|
: attachment.content_type?.startsWith("audio/") ? "🎶"
|
||||||
: "📄"
|
: "📄"
|
||||||
// no native media spoilers in Element, so we'll post a link instead, forcing it to not preview using a blockquote
|
// no native media spoilers in Element, so we'll post a link instead, forcing it to not preview using a blockquote
|
||||||
if (attachment.filename.startsWith("SPOILER_")) {
|
if (attachment.filename.startsWith("SPOILER_") || !!((attachment.flags || 0) & DiscordTypes.AttachmentFlags.IsSpoiler)) {
|
||||||
return {
|
return {
|
||||||
$type: "m.room.message",
|
$type: "m.room.message",
|
||||||
"m.mentions": mentions,
|
"m.mentions": mentions,
|
||||||
@@ -907,7 +907,14 @@ async function messageToEvent(message, guild, options = {}, di) {
|
|||||||
/** @type {{[k in keyof DiscordTypes.APIUnfurledMediaItem]-?: NonNullable<DiscordTypes.APIUnfurledMediaItem[k]>}} */ // @ts-ignore
|
/** @type {{[k in keyof DiscordTypes.APIUnfurledMediaItem]-?: NonNullable<DiscordTypes.APIUnfurledMediaItem[k]>}} */ // @ts-ignore
|
||||||
const file = component.file
|
const file = component.file
|
||||||
assert(component.name && component.size && file.content_type)
|
assert(component.name && component.size && file.content_type)
|
||||||
const ev = await attachmentToEvent({}, {...file, filename: component.name, size: component.size}, true)
|
const ev = await attachmentToEvent({}, {
|
||||||
|
filename: component.name,
|
||||||
|
content_type: file.content_type,
|
||||||
|
size: component.size,
|
||||||
|
url: file.url,
|
||||||
|
height: file.height,
|
||||||
|
width: file.width,
|
||||||
|
}, true)
|
||||||
stack.msb.addLine(ev.body, ev.formatted_body)
|
stack.msb.addLine(ev.body, ev.formatted_body)
|
||||||
}
|
}
|
||||||
else if (component.type === DiscordTypes.ComponentType.MediaGallery) {
|
else if (component.type === DiscordTypes.ComponentType.MediaGallery) {
|
||||||
|
|||||||
Reference in New Issue
Block a user