From 77732cd2b428185b896361769bf1d6caef5b42eb Mon Sep 17 00:00:00 2001 From: Jan Cernik <66427541+jancernik@users.noreply.github.com> Date: Mon, 3 Jul 2023 19:53:12 -0300 Subject: [PATCH] FIX: Minor Twitter onebox improvements (#22387) --- app/assets/stylesheets/common/base/onebox.scss | 5 +++++ lib/onebox/engine/twitter_status_onebox.rb | 7 +++++++ lib/onebox/templates/twitterstatus.mustache | 5 +++++ lib/twitter_api.rb | 14 ++++++++------ 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/common/base/onebox.scss b/app/assets/stylesheets/common/base/onebox.scss index 6661c4bb093..f69ec4cd01e 100644 --- a/app/assets/stylesheets/common/base/onebox.scss +++ b/app/assets/stylesheets/common/base/onebox.scss @@ -679,6 +679,11 @@ aside.onebox.twitterstatus .onebox-body { margin-right: 0.25em; } } + + .is-reply { + color: var(--primary-medium); + margin-right: 0.25em; + } } // Onebox - Imgur/Flickr - Album diff --git a/lib/onebox/engine/twitter_status_onebox.rb b/lib/onebox/engine/twitter_status_onebox.rb index 0c63b46a175..706751b4b98 100644 --- a/lib/onebox/engine/twitter_status_onebox.rb +++ b/lib/onebox/engine/twitter_status_onebox.rb @@ -141,6 +141,12 @@ module Onebox end end + def is_reply + if twitter_api_credentials_present? + raw.dig(:data, :referenced_tweets)&.any? { |tweet| tweet.dig(:type) == "replied_to" } + end + end + def quoted_full_name if twitter_api_credentials_present? && quoted_tweet_author.present? quoted_tweet_author[:name] @@ -216,6 +222,7 @@ module Onebox avatar: avatar, likes: likes, retweets: retweets, + is_reply: is_reply, quoted_text: quoted_text, quoted_full_name: quoted_full_name, quoted_screen_name: quoted_screen_name, diff --git a/lib/onebox/templates/twitterstatus.mustache b/lib/onebox/templates/twitterstatus.mustache index 4c94a40d081..3c3d8497aab 100644 --- a/lib/onebox/templates/twitterstatus.mustache +++ b/lib/onebox/templates/twitterstatus.mustache @@ -3,6 +3,11 @@