Skip to content

Commit

Permalink
properly show trusted circle owner
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Sep 8, 2023
1 parent 16d055f commit aa227ad
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions scripts/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,7 @@ async function appendTweet(t, timelineContainer, options = {}) {
${LOC.circle_limited_tweet.message}
<a href="https://help.twitter.com/en/using-twitter/twitter-circle" target="_blank">${LOC.learn_more.message}</a>
</div>
`.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 ? `<div class="tweet-warning">${t.tombstone}</div>` : ''}
${((t.withheld_in_countries && (t.withheld_in_countries.includes("XX") || t.withheld_in_countries.includes("XY"))) || t.withheld_scope) ? `<div class="tweet-warning">This Tweet has been withheld in response to a report from the copyright holder. <a href="https://help.twitter.com/en/rules-and-policies/copyright-policy" target="_blank">Learn more.</a></div>` : ''}
${t.conversation_control ? `<div class="tweet-warning">${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 : ''}</div>` : ''}
Expand Down
2 changes: 1 addition & 1 deletion scripts/tweetviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ class TweetViewer {
${LOC.circle_limited_tweet.message}
<a href="https://help.twitter.com/en/using-twitter/twitter-circle" target="_blank">${LOC.learn_more.message}</a>
</div>
`.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 ? `<div class="tweet-warning">${t.tombstone}</div>` : ''}
${((t.withheld_in_countries && (t.withheld_in_countries.includes("XX") || t.withheld_in_countries.includes("XY"))) || t.withheld_scope) ? `<div class="tweet-warning">This Tweet has been withheld in response to a report from the copyright holder. <a href="https://help.twitter.com/en/rules-and-policies/copyright-policy" target="_blank">Learn more.</a></div>` : ''}
${t.conversation_control ? `<div class="tweet-warning">${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 : ''}</div>` : ''}
Expand Down

0 comments on commit aa227ad

Please sign in to comment.