fedimbed: get real instance of linked post

This commit is contained in:
Cynthia Foxwell 2022-12-06 21:17:12 -07:00
parent 5ab26c461f
commit 23ae1519c3
1 changed files with 16 additions and 4 deletions

View File

@ -63,9 +63,9 @@ async function resolvePlatform(url) {
async function processUrl(msg, url) {
let urlObj = new URL(url);
const platform = await resolvePlatform(url);
const color = PLATFORM_COLORS[platform];
const platformName = platform
let platform = await resolvePlatform(url);
let color = PLATFORM_COLORS[platform];
let platformName = platform
.replace("gotosocial", "GoToSocial")
.replace(/^(.)/, (_, c) => c.toUpperCase());
@ -214,6 +214,17 @@ async function processUrl(msg, url) {
}
}
} else {
if (postData.id) {
const realUrlObj = new URL(postData.id);
if (realUrlObj.origin != urlObj.origin) {
platform = await resolvePlatform(postData.id);
color = PLATFORM_COLORS[platform];
platformName = platform
.replace("gotosocial", "GoToSocial")
.replace(/^(.)/, (_, c) => c.toUpperCase());
}
}
content =
postData._misskey_content ?? postData.source?.content ?? postData.content;
cw = postData.summary;
@ -253,9 +264,10 @@ async function processUrl(msg, url) {
});
if (authorData) {
const authorUrlObj = new URL(authorData.url);
author = {
name: authorData.name,
handle: `${authorData.preferredUsername}@${urlObj.hostname}`,
handle: `${authorData.preferredUsername}@${authorUrlObj.hostname}`,
url: authorData.url,
avatar: authorData.icon.url,
};