diff --git a/lib/routes/mastodon/utils.js b/lib/routes/mastodon/utils.js index 9fb46ddc5..1c81e6da7 100644 --- a/lib/routes/mastodon/utils.js +++ b/lib/routes/mastodon/utils.js @@ -2,36 +2,39 @@ const ProcessFeed = (data) => data.map((item) => { const content = item.content ? item.content - .replace(/|<\/span.*?>/gm, '') - .replace(/<(?:.|\n)*?>/gm, '\n') - .split('\n') - .filter((s) => s !== '')[0] + .replace(/|<\/span.*?>/gm, '') + .replace(/<(?:.|\n)*?>/gm, '\n') + .split('\n') + .filter((s) => s !== '')[0] : ''; - const media = item.media_attachments - .map((item) => { - switch (item.type) { - case 'gifv': - return `
`; - case 'video': - return `
`; - case 'image': - return `
`; - default: - return ''; - } - }) - .join(''); + const mediaParse = (media_attachments) => + media_attachments + .map((item) => { + switch (item.type) { + case 'gifv': + return `
`; + case 'video': + return `
`; + case 'image': + return `
`; + default: + return ''; + } + }) + .join(''); - let author, link, titleAuthor; + let author, link, titleAuthor, media; if (item.reblog !== null) { author = `${item.reblog.account.display_name} (@${item.reblog.account.acct})`; link = item.reblog.url; titleAuthor = `Re @${item.reblog.account.username}`; + media = mediaParse(item.reblog.media_attachments); } else { author = `${item.account.display_name} (@${item.account.acct})`; link = item.url; titleAuthor = `@${item.account.username}`; + media = mediaParse(item.media_attachments); } const titleText = item.sentitive === true ? `(CW) ${item.spoiler_text}` : content;