diff --git a/src/modules/fedimbed.js b/src/modules/fedimbed.js index 8404a77..e98aa07 100644 --- a/src/modules/fedimbed.js +++ b/src/modules/fedimbed.js @@ -847,7 +847,7 @@ async function fetchPost(url, platform, forceMastoAPI = false) { redirUrl = urlObj.origin + "/api/v1/statuses/" + postId; } else if (PATH_REGEX.mastodon2.test(urlObj.pathname)) { redirUrl = url.replace(/^\/(.+?)\/statuses/, "/api/v1/statuses"); - } else if (PATH_REGEX.twitter.text(urlObj.pathname)) { + } else if (PATH_REGEX.twitter.test(urlObj.pathname)) { const postId = urlObj.pathname.match(PATH_REGEX.twitter)?.[2]; redirUrl = urlObj.origin + "/api/v1/statuses/" + postId; } else if (PATH_REGEX.misskey.test(urlObj.pathname)) { diff --git a/src/modules/utility/presence.js b/src/modules/utility/presence.js index 3e5487d..10669d8 100644 --- a/src/modules/utility/presence.js +++ b/src/modules/utility/presence.js @@ -389,29 +389,33 @@ presence.callback = async function (msg, line) { image_links.push({label: "Small Image", url: fixMediaProxyURL(smallUrl)}); } - const largeImage = await fetch(largeUrl) - .then((res) => res.arrayBuffer()) - .then((b) => Buffer.from(b)); - const presenceImage = sharp(largeImage).resize(100, 100); - if (smallUrl) { - const smallImage = await fetch(smallUrl) + try { + const largeImage = await fetch(largeUrl) .then((res) => res.arrayBuffer()) .then((b) => Buffer.from(b)); - const smallImageBuffer = await sharp(smallImage).resize(32, 32).toBuffer(); + const presenceImage = sharp(largeImage).resize(100, 100); + if (smallUrl) { + const smallImage = await fetch(smallUrl) + .then((res) => res.arrayBuffer()) + .then((b) => Buffer.from(b)); + const smallImageBuffer = await sharp(smallImage).resize(32, 32).toBuffer(); - presenceImage.composite([ - { - input: smallImageBuffer, - gravity: "southeast", - }, - ]); + presenceImage.composite([ + { + input: smallImageBuffer, + gravity: "southeast", + }, + ]); + } + + files.push({ + contents: await presenceImage.toBuffer(), + name: `${index}.png`, + }); + thumbnail = `attachment://${index}.png`; + } catch { + thumbnail = fixMediaProxyURL(largeUrl); } - - files.push({ - contents: await presenceImage.toBuffer(), - name: `${index}.png`, - }); - thumbnail = `attachment://${index}.png`; } else if (!activity.assets.large_image && activity.assets.small_image != null) { let smallUrl; if (activity.assets.small_image.startsWith("mp:")) { diff --git a/src/util/dconstants.js b/src/util/dconstants.js index 89198b7..03cd0df 100644 --- a/src/util/dconstants.js +++ b/src/util/dconstants.js @@ -68,7 +68,15 @@ module.exports.ApplicationFlags.SOCIAL_LAYER_INTEGRATION = 1 << 27; // module.exports.ApplicationFlags.PROMOTED = 1 << 29; // prettier-ignore module.exports.ApplicationFlags.PARTNER = 1 << 30; // prettier-ignore -module.exports.ApplicationTypes = ["Normal", "Game", "Music", "Ticketed Event", "Creator Monetization", "Game"]; +module.exports.ApplicationTypes = [ + "Normal", + "Game", + "Music", + "Ticketed Event", + "Creator Monetization", + "Game", + "Non-Game Detectable", +]; module.exports.AuditLogActions.SOUNDBOARD_SOUND_CREATE = 130; module.exports.AuditLogActions.SOUNDBOARD_SOUND_UPDATE = 131;