fix(route): Add missing first part of rattibha threads (#12633)

* fix(route): Add missing first part of rattibha threads

Signed-off-by: Youssif Shaaban Alsager <ysh-alsager@hotmail.com>

* fix(route): Use correct cache key for getting rattibha thread

* fix(route): Cache item cottectly in rattibha thread

---------

Signed-off-by: Youssif Shaaban Alsager <ysh-alsager@hotmail.com>
This commit is contained in:
Youssif Shaaban Alsager
2023-06-11 18:49:17 +08:00
committed by GitHub
parent fe454d9f7e
commit e9c3d4848c
+6 -4
View File
@@ -21,15 +21,17 @@ module.exports = async (ctx) => {
pubDate: parseDate(item.thread.created_at),
updated: parseDate(item.thread.updated_at),
author: userData.name,
api_link: `${baseUrl}/threads?id=${item.thread_id}`,
threadData1URL: `${baseUrl}/thread?id=${item.thread_id}`,
threadData2URL: `${baseUrl}/threads?id=${item.thread_id}`,
}));
// Get tweet full text
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.api_link, async () => {
const { data: threads } = await got(item.api_link, { headers: { accept: 'application/json' } });
item.description = threads.reduce((accumulator, tweet) => `${accumulator}${tweet.tweet_detail.info.text}<br>`, '');
ctx.cache.tryGet(item.link, async () => {
const { data: data1 } = await got(item.threadData1URL, { headers: { accept: 'application/json' } });
const { data: data2 } = await got(item.threadData2URL, { headers: { accept: 'application/json' } });
item.description = [...data1.tweets, ...data2].reduce((accumulator, tweet) => `${accumulator}${tweet.tweet_detail.info.text}<br>`, '');
return item;
})
)