fix(route/twitter/web-api): empty rslt not skipped (#11482)

Signed-off-by: Rongrong <i@rong.moe>

Signed-off-by: Rongrong <i@rong.moe>
This commit is contained in:
Rongrong
2022-12-22 00:04:14 +08:00
committed by GitHub
parent dc52c0bab7
commit df521a6f2c

View File

@@ -115,8 +115,9 @@ function gatherLegacyFromData(entries, filter = 'tweet-') {
const tweets = []; const tweets = [];
entries.forEach((entry) => { entries.forEach((entry) => {
if (entry.entryId && entry.entryId.includes(filter)) { if (entry.entryId && entry.entryId.includes(filter)) {
const tweet = entry.content.itemContent.tweet_results.result; const tweet = entry.content.itemContent.tweet_results?.result;
const retweet = tweet.legacy.retweeted_status_result?.result; if (tweet) {
const retweet = tweet.legacy?.retweeted_status_result?.result;
for (const t of [tweet, retweet]) { for (const t of [tweet, retweet]) {
if (!t?.legacy) { if (!t?.legacy) {
continue; continue;
@@ -129,11 +130,14 @@ function gatherLegacyFromData(entries, filter = 'tweet-') {
} }
} }
const legacy = tweet.legacy; const legacy = tweet.legacy;
if (legacy) {
if (retweet) { if (retweet) {
legacy.retweeted_status = retweet.legacy; legacy.retweeted_status = retweet.legacy;
} }
tweets.push(legacy); tweets.push(legacy);
} }
}
}
}); });
return tweets; return tweets;
} }