Compare commits

...

2 commits

Author SHA1 Message Date
9c07d23f90
presence: somehow didnt try catch this 2025-12-01 16:15:45 -07:00
80b59f5046
fedimbed: epic typo 2025-12-01 16:13:47 -07:00
3 changed files with 33 additions and 21 deletions

View file

@ -847,7 +847,7 @@ async function fetchPost(url, platform, forceMastoAPI = false) {
redirUrl = urlObj.origin + "/api/v1/statuses/" + postId; redirUrl = urlObj.origin + "/api/v1/statuses/" + postId;
} else if (PATH_REGEX.mastodon2.test(urlObj.pathname)) { } else if (PATH_REGEX.mastodon2.test(urlObj.pathname)) {
redirUrl = url.replace(/^\/(.+?)\/statuses/, "/api/v1/statuses"); 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]; const postId = urlObj.pathname.match(PATH_REGEX.twitter)?.[2];
redirUrl = urlObj.origin + "/api/v1/statuses/" + postId; redirUrl = urlObj.origin + "/api/v1/statuses/" + postId;
} else if (PATH_REGEX.misskey.test(urlObj.pathname)) { } else if (PATH_REGEX.misskey.test(urlObj.pathname)) {

View file

@ -389,29 +389,33 @@ presence.callback = async function (msg, line) {
image_links.push({label: "Small Image", url: fixMediaProxyURL(smallUrl)}); image_links.push({label: "Small Image", url: fixMediaProxyURL(smallUrl)});
} }
const largeImage = await fetch(largeUrl) try {
.then((res) => res.arrayBuffer()) const largeImage = await fetch(largeUrl)
.then((b) => Buffer.from(b));
const presenceImage = sharp(largeImage).resize(100, 100);
if (smallUrl) {
const smallImage = await fetch(smallUrl)
.then((res) => res.arrayBuffer()) .then((res) => res.arrayBuffer())
.then((b) => Buffer.from(b)); .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([ presenceImage.composite([
{ {
input: smallImageBuffer, input: smallImageBuffer,
gravity: "southeast", 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) { } else if (!activity.assets.large_image && activity.assets.small_image != null) {
let smallUrl; let smallUrl;
if (activity.assets.small_image.startsWith("mp:")) { if (activity.assets.small_image.startsWith("mp:")) {

View file

@ -68,7 +68,15 @@ module.exports.ApplicationFlags.SOCIAL_LAYER_INTEGRATION = 1 << 27; //
module.exports.ApplicationFlags.PROMOTED = 1 << 29; // prettier-ignore module.exports.ApplicationFlags.PROMOTED = 1 << 29; // prettier-ignore
module.exports.ApplicationFlags.PARTNER = 1 << 30; // 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_CREATE = 130;
module.exports.AuditLogActions.SOUNDBOARD_SOUND_UPDATE = 131; module.exports.AuditLogActions.SOUNDBOARD_SOUND_UPDATE = 131;