From 84de2c5f4a39b3bde7cb5728e70317b195bfcb3f Mon Sep 17 00:00:00 2001 From: Vincent Cloutier Date: Sat, 26 Nov 2022 16:58:35 -0500 Subject: [PATCH] added replies --- .../TwitterTweetsService.cs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/BirdsiteLive.Twitter/TwitterTweetsService.cs b/src/BirdsiteLive.Twitter/TwitterTweetsService.cs index 3b22d3b..05650e0 100644 --- a/src/BirdsiteLive.Twitter/TwitterTweetsService.cs +++ b/src/BirdsiteLive.Twitter/TwitterTweetsService.cs @@ -159,6 +159,22 @@ namespace BirdsiteLive.Twitter JsonElement retweet; TwitterUser OriginalAuthor; + JsonElement inReplyToPostIdElement; + JsonElement inReplyToUserElement; + string inReplyToUser = null; + long? inReplyToPostId = null; + + bool isReply = tweet.GetProperty("content").GetProperty("itemContent") + .GetProperty("tweet_results").GetProperty("result").GetProperty("legacy") + .TryGetProperty("in_reply_to_status_id_str", out inReplyToPostIdElement); + tweet.GetProperty("content").GetProperty("itemContent") + .GetProperty("tweet_results").GetProperty("result").GetProperty("legacy") + .TryGetProperty("in_reply_to_screen_name", out inReplyToUserElement); + if (isReply) + { + inReplyToPostId = Int64.Parse(inReplyToPostIdElement.GetString()); + inReplyToUser = inReplyToUserElement.GetString(); + } bool isRetweet = tweet.GetProperty("content").GetProperty("itemContent") .GetProperty("tweet_results").GetProperty("result").GetProperty("legacy") .TryGetProperty("retweeted_status_result", out retweet); @@ -190,11 +206,11 @@ namespace BirdsiteLive.Twitter var extractedTweet = new ExtractedTweet { Id = Int64.Parse(tweet.GetProperty("sortIndex").GetString()), - InReplyToStatusId = null, - InReplyToAccount = null, + InReplyToStatusId = inReplyToPostId, + InReplyToAccount = inReplyToUser, MessageContent = MessageContent, CreatedAt = DateTime.ParseExact(creationTime, "ddd MMM dd HH:mm:ss yyyy", System.Globalization.CultureInfo.InvariantCulture), - IsReply = false, + IsReply = isReply, IsThread = false, IsRetweet = isRetweet, Media = null,