fedimbed: link emotes
This commit is contained in:
parent
ffa23ed68f
commit
945c9e7335
1 changed files with 15 additions and 3 deletions
|
@ -112,7 +112,11 @@ async function processUrl(msg, url, spoiler = false) {
|
||||||
const images = [];
|
const images = [];
|
||||||
const videos = [];
|
const videos = [];
|
||||||
const audios = [];
|
const audios = [];
|
||||||
let content, cw, author, timestamp;
|
let content,
|
||||||
|
cw,
|
||||||
|
author,
|
||||||
|
timestamp,
|
||||||
|
emotes = [];
|
||||||
|
|
||||||
// Fetch post
|
// Fetch post
|
||||||
let rawPostData;
|
let rawPostData;
|
||||||
|
@ -296,6 +300,9 @@ async function processUrl(msg, url, spoiler = false) {
|
||||||
if (!spoiler && postData2.sensitive) {
|
if (!spoiler && postData2.sensitive) {
|
||||||
spoiler = true;
|
spoiler = true;
|
||||||
}
|
}
|
||||||
|
emotes = postData2.emojis
|
||||||
|
.filter((x) => !x.name.endsWith("@."))
|
||||||
|
.map((x) => ({name: `:${x.name}:`, url: x.url}));
|
||||||
|
|
||||||
const attachments = postData2.media_attachments ?? postData2.files;
|
const attachments = postData2.media_attachments ?? postData2.files;
|
||||||
if (attachments) {
|
if (attachments) {
|
||||||
|
@ -347,8 +354,6 @@ async function processUrl(msg, url, spoiler = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (platform == "gotosocial") console.log(postData);
|
|
||||||
|
|
||||||
content =
|
content =
|
||||||
postData._misskey_content ?? postData.source?.content ?? postData.content;
|
postData._misskey_content ?? postData.source?.content ?? postData.content;
|
||||||
cw = postData.summary;
|
cw = postData.summary;
|
||||||
|
@ -356,6 +361,9 @@ async function processUrl(msg, url, spoiler = false) {
|
||||||
if (!spoiler && postData.sensitive) {
|
if (!spoiler && postData.sensitive) {
|
||||||
spoiler = true;
|
spoiler = true;
|
||||||
}
|
}
|
||||||
|
emotes = postData.tag
|
||||||
|
.filter((x) => !!x.icon)
|
||||||
|
.map((x) => ({name: x.name, url: x.icon.url}));
|
||||||
|
|
||||||
// NB: gts doesnt send singular attachments as areay
|
// NB: gts doesnt send singular attachments as areay
|
||||||
const attachments = Array.isArray(postData.attachment)
|
const attachments = Array.isArray(postData.attachment)
|
||||||
|
@ -428,6 +436,10 @@ async function processUrl(msg, url, spoiler = false) {
|
||||||
content = content.replace(/(<([^>]+)>)/gi, "");
|
content = content.replace(/(<([^>]+)>)/gi, "");
|
||||||
content = parseHtmlEntities(content);
|
content = parseHtmlEntities(content);
|
||||||
|
|
||||||
|
for (const emote of emotes) {
|
||||||
|
content = content.replaceAll(emote.name, `[${emote.name}](${emote.url})`);
|
||||||
|
}
|
||||||
|
|
||||||
cw = cw.replace(/(<([^>]+)>)/gi, "");
|
cw = cw.replace(/(<([^>]+)>)/gi, "");
|
||||||
cw = parseHtmlEntities(cw);
|
cw = parseHtmlEntities(cw);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue