# HG changeset patch # User nanaya # Date 1689353585 -32400 # Node ID a04b4830eef25162d07e9a63eb989f6d155d65c0 # Parent 961d362e42c7fce2bfeeef1f03dcde2088c38dae Filter out non-own tweets included for replies diff -r 961d362e42c7 -r a04b4830eef2 app/lib/legit_client.rb --- a/app/lib/legit_client.rb Sat Jul 15 01:47:34 2023 +0900 +++ b/app/lib/legit_client.rb Sat Jul 15 01:53:05 2023 +0900 @@ -5,7 +5,7 @@ begin json = JSON.parse(resp) { - timeline: normalize_timeline(json['data']['user']['result']['timeline_v2']['timeline']['instructions']), + timeline: normalize_timeline(json['data']['user']['result']['timeline_v2']['timeline']['instructions'], user_id), raw: resp, } rescue => e @@ -102,7 +102,7 @@ ret end - def self.normalize_timeline(json) + def self.normalize_timeline(json, user_id) json.find { |instruction| instruction['type'] == 'TimelineAddEntries' }['entries'] .filter { |entry| entry['entryId'] =~ /\A(profile-conversation|tweet)-/ } .reduce([]) do |acc, entry| @@ -115,6 +115,7 @@ end acc end.map { |rawTweet| normalize_tweet(rawTweet['itemContent']['tweet_results']['result']) } + .filter { |tweet| !tweet.nil? && tweet.dig(:user, :id) == user_id } end def self.normalize_tweet(json)