From cb03dd305928f229af0e72a8471cb70ca646daf9 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Tue, 10 Jan 2023 17:57:53 +0000 Subject: [PATCH] feat: quote repost and reply info for twitter and jike --- lib/v2/jike/user.js | 11 +++++++---- lib/v2/twitter/utils.js | 32 ++++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/lib/v2/jike/user.js b/lib/v2/jike/user.js index 9f226f3ff..30a8cdc37 100644 --- a/lib/v2/jike/user.js +++ b/lib/v2/jike/user.js @@ -109,10 +109,13 @@ module.exports = async (ctx) => { pubDate: parseDate(item.createdAt), link: getLink(item.id, item.type), _extra: repostContent && { - quote: { - url: getLink(item.target.id, item.target.type), - content_html: repostContent, - }, + links: [ + { + url: getLink(item.target.id, item.target.type), + content_html: repostContent, + type: 'quote', + }, + ], }, }; diff --git a/lib/v2/twitter/utils.js b/lib/v2/twitter/utils.js index 15a2c9737..c369e4bfb 100644 --- a/lib/v2/twitter/utils.js +++ b/lib/v2/twitter/utils.js @@ -385,12 +385,32 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => { pubDate: parseDate(item.created_at), link: `https://twitter.com/${item.user.screen_name}/status/${item.id_str}`, - _extra: item.is_quote_status && { - quote: { - url: `https://twitter.com/${item.quoted_status.user?.screen_name}/status/${item.quoted_status.id_str}`, - content_html: quote, - }, - }, + _extra: + (isRetweet && { + links: [ + { + type: 'repost', + }, + ], + }) || + (item.is_quote_status && { + links: [ + { + url: `https://twitter.com/${item.quoted_status.user?.screen_name}/status/${item.quoted_status.id_str}`, + content_html: quote, + type: 'quote', + }, + ], + }) || + (item.in_reply_to_screen_name && + item.in_reply_to_status_id_str && { + links: [ + { + url: `https://twitter.com/${item.in_reply_to_screen_name}/status/${item.in_reply_to_status_id_str}`, + type: 'reply', + }, + ], + }), }; }); };