diff --git a/lib/v2/twitter/utils.js b/lib/v2/twitter/utils.js index 15a3924e2..36fb991df 100644 --- a/lib/v2/twitter/utils.js +++ b/lib/v2/twitter/utils.js @@ -31,9 +31,11 @@ const replaceBreak = (text) => text.replaceAll(/

|
/g, ' '); const formatText = (item) => { let text = item.full_text; + const id_str = item.id_str || item.conversation_id_str; const urls = item.entities.urls || []; for (const url of urls) { - text = text.replaceAll(url.url, url.expanded_url); + // trim link pointing to the tweet itself (usually appears when the tweet is truncated) + text = text.replaceAll(url.url, url.expanded_url.endsWith(id_str) ? '' : url.expanded_url); } const media = item.extended_entities?.media || []; for (const m of media) { @@ -361,20 +363,27 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => { description += quote; if (readable) { - description += `

`; + description += `
`; } if (showTimestampInDescription) { + if (readable) { + description += `
`; + } description += `${parseDate(item.created_at)}`; } const authorName = originalItem.user.name; + const link = + originalItem.user.screen_name && (originalItem.id_str || originalItem.conversation_id_str) + ? `https://twitter.com/${originalItem.user.screen_name}/status/${originalItem.id_str || originalItem.conversation_id_str}` + : `https://twitter.com/${item.user.screen_name}/status/${item.id_str || item.conversation_id_str}`; return { title, author: authorName, description, pubDate: parseDate(item.created_at), - link: `https://twitter.com/${item.user.screen_name}/status/${item.id_str || item.conversation_id_str}`, + link, _extra: (isRetweet && {