diff --git a/src/BirdsiteLive.Twitter/TwitterTweetsService.cs b/src/BirdsiteLive.Twitter/TwitterTweetsService.cs index 6577cda..bd879b9 100644 --- a/src/BirdsiteLive.Twitter/TwitterTweetsService.cs +++ b/src/BirdsiteLive.Twitter/TwitterTweetsService.cs @@ -76,11 +76,6 @@ namespace BirdsiteLive.Twitter public async Task GetTimelineAsync(string username, int nberTweets, long fromTweetId = -1) { - if (nberTweets < 5) - nberTweets = 5; - - if (nberTweets > 100) - nberTweets = 100; var client = await _twitterAuthenticationInitializer.MakeHttpClient(); @@ -131,6 +126,9 @@ namespace BirdsiteLive.Twitter { var extractedTweet = await Extract(tweet); extractedTweets.Add(extractedTweet); + + if (extractedTweet.Id == fromTweetId) + break; } catch (Exception e) diff --git a/src/Tests/BirdsiteLive.Twitter.Tests/TimelineTests.cs b/src/Tests/BirdsiteLive.Twitter.Tests/TimelineTests.cs index c62b1ce..79b170c 100644 --- a/src/Tests/BirdsiteLive.Twitter.Tests/TimelineTests.cs +++ b/src/Tests/BirdsiteLive.Twitter.Tests/TimelineTests.cs @@ -27,9 +27,11 @@ namespace BirdsiteLive.ActivityPub.Tests [TestMethod] public async Task TimelineKobe() { - var tweets = await _tweetService.GetTimelineAsync("kobebryant", 100, 100000); + var tweets = await _tweetService.GetTimelineAsync("kobebryant", 100, 1218020971346444288); Assert.AreEqual(tweets[0].MessageContent, "Continuing to move the game forward @KingJames. Much respect my brother 💪🏾 #33644"); + Assert.AreEqual(tweets.Length, 9); } + } }