better loggin

This commit is contained in:
Nicolas Constant
2022-12-28 18:00:24 -05:00
parent eccd9bdd28
commit e950801f56

View File

@@ -14,6 +14,7 @@ using BirdsiteLive.DAL.Models;
using BirdsiteLive.Domain.Enum;
using System.Net.Http;
using BirdsiteLive.Common.Regexes;
using Microsoft.Extensions.Logging;
namespace BirdsiteLive.Domain
{
@@ -26,9 +27,10 @@ namespace BirdsiteLive.Domain
private readonly ITwitterUserDal _twitterUserDal;
private readonly IFollowersDal _followersDal;
private readonly IHttpClientFactory _httpClientFactory;
private readonly ILogger<MigrationService> _logger;
#region Ctor
public MigrationService(ITwitterTweetsService twitterTweetsService, IActivityPubService activityPubService, ITwitterUserDal twitterUserDal, IFollowersDal followersDal, InstanceSettings instanceSettings, ITheFedInfoService theFedInfoService, IHttpClientFactory httpClientFactory)
public MigrationService(ITwitterTweetsService twitterTweetsService, IActivityPubService activityPubService, ITwitterUserDal twitterUserDal, IFollowersDal followersDal, InstanceSettings instanceSettings, ITheFedInfoService theFedInfoService, IHttpClientFactory httpClientFactory, ILogger<MigrationService> logger)
{
_twitterTweetsService = twitterTweetsService;
_activityPubService = activityPubService;
@@ -37,6 +39,7 @@ namespace BirdsiteLive.Domain
_instanceSettings = instanceSettings;
_theFedInfoService = theFedInfoService;
_httpClientFactory = httpClientFactory;
_logger = logger;
}
#endregion
@@ -187,7 +190,7 @@ namespace BirdsiteLive.Domain
}
catch (Exception e)
{
Console.WriteLine(e);
_logger.LogError(e, e.Message);
}
}
});
@@ -231,8 +234,15 @@ namespace BirdsiteLive.Domain
var sharedInbox = followerGroup.First().SharedInboxRoute;
var t1 = Task.Run(async () =>
{
try
{
await _activityPubService.DeleteUserAsync(acct, host, sharedInbox);
}
catch (Exception e)
{
_logger.LogError(e, e.Message);
}
});
}
@@ -245,8 +255,15 @@ namespace BirdsiteLive.Domain
var sharedInbox = followerGroup.InboxRoute;
var t1 = Task.Run(async () =>
{
try
{
await _activityPubService.DeleteUserAsync(acct, host, sharedInbox);
}
catch (Exception e)
{
_logger.LogError(e, e.Message);
}
});
}
});
@@ -287,13 +304,13 @@ namespace BirdsiteLive.Domain
}
catch (Exception e)
{
Console.WriteLine(e);
_logger.LogError(e, e.Message);
}
}
}
catch (Exception e)
{
Console.WriteLine(e);
_logger.LogError(e, e.Message);
}
}