From 52678c9eefecdbee9b0c2ec5ae36c6e3d6ff095c Mon Sep 17 00:00:00 2001 From: DIYgod Date: Mon, 30 Jan 2023 22:00:07 +0000 Subject: [PATCH] feat: generate quote content_html, telegram channel repost extra data --- lib/middleware/parameter.js | 5 +++++ lib/v2/jike/user.js | 1 - lib/v2/telegram/channel.js | 12 ++++++++++++ lib/v2/twitter/utils.js | 1 - 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/middleware/parameter.js b/lib/middleware/parameter.js index 9bf0fb03ab..ac7674ab68 100644 --- a/lib/middleware/parameter.js +++ b/lib/middleware/parameter.js @@ -139,6 +139,11 @@ module.exports = async (ctx, next) => { }); item.description = $('body').html() + '' + (config.suffix || ''); + + const quote = item._extra?.links?.find((e) => e.type === 'quote'); + if (quote && $('.rsshub-quote').length) { + quote.content_html = $.html($('.rsshub-quote')); + } } return item; }; diff --git a/lib/v2/jike/user.js b/lib/v2/jike/user.js index 30a8cdc371..f9d5832f92 100644 --- a/lib/v2/jike/user.js +++ b/lib/v2/jike/user.js @@ -112,7 +112,6 @@ module.exports = async (ctx) => { links: [ { url: getLink(item.target.id, item.target.type), - content_html: repostContent, type: 'quote', }, ], diff --git a/lib/v2/telegram/channel.js b/lib/v2/telegram/channel.js index 43483f7213..f3813e146c 100644 --- a/lib/v2/telegram/channel.js +++ b/lib/v2/telegram/channel.js @@ -120,6 +120,7 @@ module.exports = async (ctx) => { list .map((index, item) => { item = $(item); + let extra = null; /* message types */ let msgTypes = []; @@ -208,6 +209,15 @@ module.exports = async (ctx) => { fwdFrom += ` (${fwdFromAuthorObj.text()})`; } fwdFrom += '

'; + + extra = { + links: [ + { + type: 'repost', + url: userLink, + }, + ], + }; } return fwdFrom; }; @@ -576,6 +586,8 @@ module.exports = async (ctx) => { enclosure_url: voiceUrl, itunes_duration: voiceDuration(), enclosure_type: 'audio/ogg', + + _extra: extra, }; }) .get() diff --git a/lib/v2/twitter/utils.js b/lib/v2/twitter/utils.js index d09d31541e..aa8b11ff62 100644 --- a/lib/v2/twitter/utils.js +++ b/lib/v2/twitter/utils.js @@ -397,7 +397,6 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => { links: [ { url: `https://twitter.com/${item.quoted_status?.user?.screen_name}/status/${item.quoted_status?.id_str}`, - content_html: quote, type: 'quote', }, ],