diff --git a/src/BirdsiteLive.Twitter/TwitterTweetsService.cs b/src/BirdsiteLive.Twitter/TwitterTweetsService.cs index 6be8697..788f046 100644 --- a/src/BirdsiteLive.Twitter/TwitterTweetsService.cs +++ b/src/BirdsiteLive.Twitter/TwitterTweetsService.cs @@ -209,6 +209,16 @@ namespace BirdsiteLive.Twitter .GetProperty("tweet_results").GetProperty("result").GetProperty("legacy") .TryGetProperty("extended_entities", out extendedEntities); + JsonElement.ArrayEnumerator urls = tweet.GetProperty("content").GetProperty("itemContent") + .GetProperty("tweet_results").GetProperty("result").GetProperty("legacy") + .GetProperty("entities").GetProperty("urls").EnumerateArray(); + foreach (JsonElement url in urls) + { + string tco = url.GetProperty("url").GetString(); + string goodUrl = url.GetProperty("expanded_url").GetString(); + MessageContent = MessageContent.Replace(tco, goodUrl); + } + List Media = new List(); if (hasMedia) { diff --git a/src/Tests/BirdsiteLive.Twitter.Tests/TweetTests.cs b/src/Tests/BirdsiteLive.Twitter.Tests/TweetTests.cs index 2f45284..b81e3b1 100644 --- a/src/Tests/BirdsiteLive.Twitter.Tests/TweetTests.cs +++ b/src/Tests/BirdsiteLive.Twitter.Tests/TweetTests.cs @@ -36,7 +36,16 @@ namespace BirdsiteLive.ActivityPub.Tests { var tweet = await _tweetService.GetTweetAsync(1593344577385160704); Assert.AreEqual(tweet.MessageContent, "Speaker Nancy Pelosi will go down as one of most accomplished legislators in American history—breaking barriers, opening doors for others, and working every day to serve the American people. I couldn’t be more grateful for her friendship and leadership."); + + // TODO validate media type and length + // TODO test alt-text of images } + [TestMethod] + public async Task SimpleTextAndSingleLinkTweet() + { + var tweet = await _tweetService.GetTweetAsync(1602618920996945922); + Assert.AreEqual(tweet.MessageContent, "#Linux 6.2 Expands Support For More #Qualcomm #Snapdragon SoCs, #Apple M1 Pro/Ultra/Max\n\nhttps://www.phoronix.com/news/Linux-6.2-Arm-SoC-Updates"); + } } } \ No newline at end of file