fedimbed: limmy support
This commit is contained in:
parent
690a8f8765
commit
a0c037b6e9
1 changed files with 48 additions and 20 deletions
|
@ -23,6 +23,7 @@ const PATH_REGEX = {
|
||||||
pleroma2: /^\/notice\/[A-Za-z0-9]+\/?/,
|
pleroma2: /^\/notice\/[A-Za-z0-9]+\/?/,
|
||||||
misskey: /^\/notes\/[a-z0-9]+\/?/,
|
misskey: /^\/notes\/[a-z0-9]+\/?/,
|
||||||
gotosocial: /^\/@(.+?)\/statuses\/[0-9A-Z]+\/?/,
|
gotosocial: /^\/@(.+?)\/statuses\/[0-9A-Z]+\/?/,
|
||||||
|
lemmy: /^\/post\/\d+\/?/,
|
||||||
};
|
};
|
||||||
|
|
||||||
const PLATFORM_COLORS = {
|
const PLATFORM_COLORS = {
|
||||||
|
@ -33,6 +34,7 @@ const PLATFORM_COLORS = {
|
||||||
calckey: 0x31748f,
|
calckey: 0x31748f,
|
||||||
firefish: 0xf07a5b, // YCbCr interpolated color from the two logo colors
|
firefish: 0xf07a5b, // YCbCr interpolated color from the two logo colors
|
||||||
gotosocial: 0xff853e,
|
gotosocial: 0xff853e,
|
||||||
|
lemmy: 0x14854f,
|
||||||
};
|
};
|
||||||
|
|
||||||
const domainCache = new Map();
|
const domainCache = new Map();
|
||||||
|
@ -116,6 +118,7 @@ async function processUrl(msg, url, spoiler = false) {
|
||||||
cw,
|
cw,
|
||||||
author,
|
author,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
title,
|
||||||
emotes = [];
|
emotes = [];
|
||||||
|
|
||||||
// Fetch post
|
// Fetch post
|
||||||
|
@ -370,27 +373,42 @@ async function processUrl(msg, url, spoiler = false) {
|
||||||
? postData.attachment
|
? postData.attachment
|
||||||
: [postData.attachment];
|
: [postData.attachment];
|
||||||
for (const attachment of attachments) {
|
for (const attachment of attachments) {
|
||||||
if (attachment.mediaType.startsWith("video/")) {
|
if (attachment.mediaType) {
|
||||||
videos.push({
|
if (attachment.mediaType.startsWith("video/")) {
|
||||||
url: attachment.url,
|
videos.push({
|
||||||
desc: attachment.name,
|
url: attachment.url,
|
||||||
type: attachment.mediaType,
|
desc: attachment.name,
|
||||||
});
|
type: attachment.mediaType,
|
||||||
} else if (attachment.mediaType.startsWith("image/")) {
|
});
|
||||||
images.push({
|
} else if (attachment.mediaType.startsWith("image/")) {
|
||||||
url: attachment.url,
|
images.push({
|
||||||
desc: attachment.name,
|
url: attachment.url,
|
||||||
type: attachment.mediaType,
|
desc: attachment.name,
|
||||||
});
|
type: attachment.mediaType,
|
||||||
} else if (attachment.mediaType.startsWith("audio/")) {
|
});
|
||||||
audios.push({
|
} else if (attachment.mediaType.startsWith("audio/")) {
|
||||||
url: attachment.url,
|
audios.push({
|
||||||
desc: attachment.name,
|
url: attachment.url,
|
||||||
type: attachment.mediaType,
|
desc: attachment.name,
|
||||||
});
|
type: attachment.mediaType,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (postData.image?.url) {
|
||||||
|
const imageUrl = new URL(postData.image?.url);
|
||||||
|
images.push({
|
||||||
|
url: postData.image?.url,
|
||||||
|
desc: "",
|
||||||
|
type:
|
||||||
|
"image/" +
|
||||||
|
imageUrl.pathname.substring(imageUrl.pathname.lastIndexOf(".") + 1),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (postData.name) title = postData.name;
|
||||||
|
|
||||||
// Author data is not sent with the post with AS2
|
// Author data is not sent with the post with AS2
|
||||||
const authorData = await signedFetch(
|
const authorData = await signedFetch(
|
||||||
postData.actor ?? postData.attributedTo,
|
postData.actor ?? postData.attributedTo,
|
||||||
|
@ -466,12 +484,22 @@ async function processUrl(msg, url, spoiler = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const user = author.name
|
||||||
|
? `${author.name} (${author.handle})`
|
||||||
|
: author.handle;
|
||||||
|
|
||||||
const baseEmbed = {
|
const baseEmbed = {
|
||||||
color,
|
color,
|
||||||
url,
|
url,
|
||||||
timestamp,
|
timestamp,
|
||||||
description: desc,
|
description: desc,
|
||||||
title: `${author.name} (${author.handle})`,
|
title: title ?? user,
|
||||||
|
author: title
|
||||||
|
? {
|
||||||
|
name: user,
|
||||||
|
url: author.url,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
footer: {
|
footer: {
|
||||||
text: platformName,
|
text: platformName,
|
||||||
},
|
},
|
||||||
|
@ -605,7 +633,7 @@ async function processUrl(msg, url, spoiler = false) {
|
||||||
.replace("/", ".")
|
.replace("/", ".")
|
||||||
.replace("mpeg", "mp3")
|
.replace("mpeg", "mp3")
|
||||||
.replace("vnd.wave", "wav")
|
.replace("vnd.wave", "wav")
|
||||||
.replace("x-wav", "wav")
|
.replace("x-", "")
|
||||||
: attachment.type +
|
: attachment.type +
|
||||||
"." +
|
"." +
|
||||||
(url.match(/\.([a-z0-9]{3,4})$/)?.[0] ?? "mp3")),
|
(url.match(/\.([a-z0-9]{3,4})$/)?.[0] ?? "mp3")),
|
||||||
|
|
Loading…
Reference in a new issue