diff --git a/src/modules/fedimbed.js b/src/modules/fedimbed.js index 9f8cbfa..be3cd4e 100644 --- a/src/modules/fedimbed.js +++ b/src/modules/fedimbed.js @@ -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, };