make user retrieval more resilient

This commit is contained in:
Nicolas Constant 2021-01-29 23:10:02 -05:00
parent 739f7aaead
commit 1d5df9a83b
No known key found for this signature in database
GPG key ID: 1E9F677FB01A5688
2 changed files with 9 additions and 5 deletions

View file

@ -59,13 +59,13 @@ namespace BirdsiteLive.Twitter
public ExtractedTweet[] GetTimeline(string username, int nberTweets, long fromTweetId = -1)
{
TweetinviConfig.CurrentThreadSettings.TweetMode = TweetMode.Extended;
var user = _twitterUserService.GetUser(username);
if (user.Protected) return new ExtractedTweet[0];
var tweets = new List<ITweet>();
try
{
var user = _twitterUserService.GetUser(username);
if (user == null || user.Protected) return new ExtractedTweet[0];
if (fromTweetId == -1)
{
var timeline = Timeline.GetUserTimeline(user.Id, nberTweets);

View file

@ -38,7 +38,11 @@ namespace BirdsiteLive.Twitter
{
user = User.GetUserFromScreenName(username);
_statisticsHandler.CalledUserApi();
if (user == null) return null;
if (user == null)
{
_logger.LogWarning("User {username} not found", username);
return null;
}
}
catch (Exception e)
{