From aa227addc5fc2c784cd299df3285d9550b254f71 Mon Sep 17 00:00:00 2001 From: dimden Date: Fri, 8 Sep 2023 22:21:00 +0300 Subject: [PATCH] properly show trusted circle owner --- scripts/apis.js | 6 ++++++ scripts/helpers.js | 2 +- scripts/tweetviewer.js | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/apis.js b/scripts/apis.js index 13d2626f..4a8e46d1 100644 --- a/scripts/apis.js +++ b/scripts/apis.js @@ -225,6 +225,9 @@ function parseTweet(res) { if(res.birdwatch_pivot) { // community notes tweet.birdwatch = res.birdwatch_pivot; } + if(res.trusted_friends_info_result && res.trusted_friends_info_result.owner_results && res.trusted_friends_info_result.owner_results.result && res.trusted_friends_info_result.owner_results.result.legacy) { + tweet.trusted_circle_owner = res.trusted_friends_info_result.owner_results.result.legacy.screen_name; + } if(tweet.favorited && tweet.favorite_count === 0) { tweet.favorite_count = 1; @@ -2483,6 +2486,9 @@ const API = { let ct = data.data.create_tweet ? data.data.create_tweet : data.data.notetweet_create; let result = ct.tweet_results.result; let tweet = parseTweet(result); + if(result.trusted_friends_info_result && !tweet.limited_actions) { + tweet.limited_actions = 'limit_trusted_friends_tweet'; + } debugLog('tweet.postV2', 'end', tweet); resolve(tweet); }).catch(e => { diff --git a/scripts/helpers.js b/scripts/helpers.js index ce782b62..76ef0c44 100644 --- a/scripts/helpers.js +++ b/scripts/helpers.js @@ -1852,7 +1852,7 @@ async function appendTweet(t, timelineContainer, options = {}) { ${LOC.circle_limited_tweet.message} ${LOC.learn_more.message} - `.replace('$SCREEN_NAME$', tweetStorage[t.conversation_id_str] ? tweetStorage[t.conversation_id_str].user.screen_name : t.in_reply_to_screen_name ? t.in_reply_to_screen_name : t.user.screen_name) : ''} + `.replace('$SCREEN_NAME$', tweet.trusted_circle_owner ? tweet.trusted_circle_owner : tweetStorage[t.conversation_id_str] ? tweetStorage[t.conversation_id_str].user.screen_name : t.in_reply_to_screen_name ? t.in_reply_to_screen_name : t.user.screen_name) : ''} ${t.tombstone ? `
${t.tombstone}
` : ''} ${((t.withheld_in_countries && (t.withheld_in_countries.includes("XX") || t.withheld_in_countries.includes("XY"))) || t.withheld_scope) ? `
This Tweet has been withheld in response to a report from the copyright holder. Learn more.
` : ''} ${t.conversation_control ? `
${t.limited_actions_text ? t.limited_actions_text : LOC.limited_tweet.message}${t.conversation_control.policy && (t.user.id_str === user.id_str || (t.conversation_control.policy.toLowerCase() === 'community' && (t.user.followed_by || (full_text && full_text.includes(`@${user.screen_name}`)))) || (t.conversation_control.policy.toLowerCase() === 'by_invitation' && full_text && full_text.includes(`@${user.screen_name}`))) ? ' ' + LOC.you_can_reply.message : ''}
` : ''} diff --git a/scripts/tweetviewer.js b/scripts/tweetviewer.js index d1409275..5b43282c 100644 --- a/scripts/tweetviewer.js +++ b/scripts/tweetviewer.js @@ -1011,7 +1011,7 @@ class TweetViewer { ${LOC.circle_limited_tweet.message} ${LOC.learn_more.message} - `.replace('$SCREEN_NAME$', tweetStorage[t.conversation_id_str] ? tweetStorage[t.conversation_id_str].user.screen_name : t.in_reply_to_screen_name ? t.in_reply_to_screen_name : t.user.screen_name) : ''} + `.replace('$SCREEN_NAME$', tweet.trusted_circle_owner ? tweet.trusted_circle_owner : tweetStorage[t.conversation_id_str] ? tweetStorage[t.conversation_id_str].user.screen_name : t.in_reply_to_screen_name ? t.in_reply_to_screen_name : t.user.screen_name) : ''} ${t.tombstone ? `
${t.tombstone}
` : ''} ${((t.withheld_in_countries && (t.withheld_in_countries.includes("XX") || t.withheld_in_countries.includes("XY"))) || t.withheld_scope) ? `
This Tweet has been withheld in response to a report from the copyright holder. Learn more.
` : ''} ${t.conversation_control ? `
${t.limited_actions_text ? t.limited_actions_text : LOC.limited_tweet.message}${t.conversation_control.policy && (t.user.id_str === user.id_str || (t.conversation_control.policy.toLowerCase() === 'community' && (t.user.followed_by || (full_text && full_text.includes(`@${user.screen_name}`)))) || (t.conversation_control.policy.toLowerCase() === 'by_invitation' && full_text && full_text.includes(`@${user.screen_name}`))) ? ' ' + LOC.you_can_reply.message : ''}
` : ''}