added tweet author
This commit is contained in:
parent
7c2dcdbcec
commit
38aa9f2c62
4 changed files with 14 additions and 1 deletions
|
@ -17,5 +17,6 @@ namespace BirdsiteLive.Twitter.Models
|
|||
public string RetweetUrl { get; set; }
|
||||
public long RetweetId { get; set; }
|
||||
public TwitterUser OriginalAuthor { get; set; }
|
||||
public TwitterUser Author { get; set; }
|
||||
}
|
||||
}
|
|
@ -179,6 +179,7 @@ namespace BirdsiteLive.Twitter
|
|||
|
||||
JsonElement retweet;
|
||||
TwitterUser OriginalAuthor;
|
||||
TwitterUser author = null;
|
||||
JsonElement inReplyToPostIdElement;
|
||||
JsonElement inReplyToUserElement;
|
||||
string inReplyToUser = null;
|
||||
|
@ -189,6 +190,12 @@ namespace BirdsiteLive.Twitter
|
|||
.GetProperty("tweet_results").GetProperty("result").GetProperty("core").GetProperty("user_results")
|
||||
.GetProperty("result").GetProperty("legacy").GetProperty("screen_name").GetString();
|
||||
|
||||
JsonElement userDoc = tweet.GetProperty("content").GetProperty("itemContent")
|
||||
.GetProperty("tweet_results").GetProperty("result").GetProperty("core")
|
||||
.GetProperty("user_results").GetProperty("result");
|
||||
|
||||
author = _twitterUserService.Extract(userDoc);
|
||||
|
||||
bool isReply = tweet.GetProperty("content").GetProperty("itemContent")
|
||||
.GetProperty("tweet_results").GetProperty("result").GetProperty("legacy")
|
||||
.TryGetProperty("in_reply_to_status_id_str", out inReplyToPostIdElement);
|
||||
|
@ -218,6 +225,7 @@ namespace BirdsiteLive.Twitter
|
|||
.GetProperty("text").GetString();
|
||||
}
|
||||
OriginalAuthor = null;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -323,6 +331,7 @@ namespace BirdsiteLive.Twitter
|
|||
quoteTweetLink = quoteTweetLink.Replace("/status/", "/statuses/");
|
||||
MessageContent = MessageContent + "\n\n" + quoteTweetLink;
|
||||
}
|
||||
|
||||
var extractedTweet = new ExtractedTweet
|
||||
{
|
||||
Id = Int64.Parse(tweet.GetProperty("entryId").GetString().Replace("tweet-", "")),
|
||||
|
@ -337,6 +346,7 @@ namespace BirdsiteLive.Twitter
|
|||
RetweetUrl = "https://t.co/123",
|
||||
RetweetId = retweetId,
|
||||
OriginalAuthor = OriginalAuthor,
|
||||
Author = author,
|
||||
};
|
||||
|
||||
return extractedTweet;
|
||||
|
|
|
@ -57,12 +57,13 @@ namespace BirdsiteLive.ActivityPub.Tests
|
|||
{
|
||||
var tweets = await _tweetService.GetTimelineAsync("grantimahara", default);
|
||||
Assert.IsTrue(tweets[0].IsReply);
|
||||
Assert.IsTrue(tweets.Length > 30);
|
||||
Assert.IsTrue(tweets.Length > 10);
|
||||
|
||||
Assert.AreEqual(tweets[2].MessageContent, "Liftoff!");
|
||||
Assert.AreEqual(tweets[2].RetweetId, 1266812530833240064);
|
||||
Assert.AreEqual(tweets[2].Id, 1266813644626489345);
|
||||
Assert.AreEqual(tweets[2].OriginalAuthor.Acct, "SpaceX");
|
||||
Assert.AreEqual(tweets[2].Author.Acct, "grantimahara");
|
||||
Assert.IsTrue(tweets[2].IsRetweet);
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@ namespace BirdsiteLive.ActivityPub.Tests
|
|||
var tweet = await _tweetService.GetTweetAsync(1610807139089383427);
|
||||
|
||||
Assert.AreEqual(tweet.MessageContent, "When you gave them your keys you gave them your coins.\n\nhttps://domain.name/users/kadhim/statuses/1610706613207285773");
|
||||
Assert.AreEqual(tweet.Author.Acct, "RyanSAdams");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
Loading…
Add table
Reference in a new issue