add better parsing error handling
This commit is contained in:
parent
7e3d7b7c4f
commit
2b765136bb
2 changed files with 43 additions and 6 deletions
|
@ -7,6 +7,7 @@ using BirdsiteLive.DAL.Contracts;
|
||||||
using BirdsiteLive.DAL.Models;
|
using BirdsiteLive.DAL.Models;
|
||||||
using BirdsiteLive.Domain;
|
using BirdsiteLive.Domain;
|
||||||
using BirdsiteLive.Twitter.Models;
|
using BirdsiteLive.Twitter.Models;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace BirdsiteLive.Pipeline.Processors.SubTasks
|
namespace BirdsiteLive.Pipeline.Processors.SubTasks
|
||||||
{
|
{
|
||||||
|
@ -20,13 +21,16 @@ namespace BirdsiteLive.Pipeline.Processors.SubTasks
|
||||||
private readonly IActivityPubService _activityPubService;
|
private readonly IActivityPubService _activityPubService;
|
||||||
private readonly IStatusService _statusService;
|
private readonly IStatusService _statusService;
|
||||||
private readonly IFollowersDal _followersDal;
|
private readonly IFollowersDal _followersDal;
|
||||||
|
private readonly ILogger<SendTweetsToInboxTask> _logger;
|
||||||
|
|
||||||
|
|
||||||
#region Ctor
|
#region Ctor
|
||||||
public SendTweetsToInboxTask(IActivityPubService activityPubService, IStatusService statusService, IFollowersDal followersDal)
|
public SendTweetsToInboxTask(IActivityPubService activityPubService, IStatusService statusService, IFollowersDal followersDal, ILogger<SendTweetsToInboxTask> logger)
|
||||||
{
|
{
|
||||||
_activityPubService = activityPubService;
|
_activityPubService = activityPubService;
|
||||||
_statusService = statusService;
|
_statusService = statusService;
|
||||||
_followersDal = followersDal;
|
_followersDal = followersDal;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -46,8 +50,23 @@ namespace BirdsiteLive.Pipeline.Processors.SubTasks
|
||||||
{
|
{
|
||||||
foreach (var tweet in tweetsToSend)
|
foreach (var tweet in tweetsToSend)
|
||||||
{
|
{
|
||||||
var note = _statusService.GetStatus(user.Acct, tweet);
|
try
|
||||||
await _activityPubService.PostNewNoteActivity(note, user.Acct, tweet.Id.ToString(), follower.Host, inbox);
|
{
|
||||||
|
var note = _statusService.GetStatus(user.Acct, tweet);
|
||||||
|
await _activityPubService.PostNewNoteActivity(note, user.Acct, tweet.Id.ToString(), follower.Host, inbox);
|
||||||
|
}
|
||||||
|
catch (ArgumentException e)
|
||||||
|
{
|
||||||
|
if (e.Message.Contains("Invalid pattern") && e.Message.Contains("at offset")) //Regex exception
|
||||||
|
{
|
||||||
|
_logger.LogError(e, "Can't parse {MessageContent} from Tweet {Id}", tweet.MessageContent, tweet.Id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
syncStatus = tweet.Id;
|
syncStatus = tweet.Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ using BirdsiteLive.DAL.Contracts;
|
||||||
using BirdsiteLive.DAL.Models;
|
using BirdsiteLive.DAL.Models;
|
||||||
using BirdsiteLive.Domain;
|
using BirdsiteLive.Domain;
|
||||||
using BirdsiteLive.Twitter.Models;
|
using BirdsiteLive.Twitter.Models;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace BirdsiteLive.Pipeline.Processors.SubTasks
|
namespace BirdsiteLive.Pipeline.Processors.SubTasks
|
||||||
{
|
{
|
||||||
|
@ -19,13 +20,15 @@ namespace BirdsiteLive.Pipeline.Processors.SubTasks
|
||||||
private readonly IStatusService _statusService;
|
private readonly IStatusService _statusService;
|
||||||
private readonly IActivityPubService _activityPubService;
|
private readonly IActivityPubService _activityPubService;
|
||||||
private readonly IFollowersDal _followersDal;
|
private readonly IFollowersDal _followersDal;
|
||||||
|
private readonly ILogger<SendTweetsToSharedInboxTask> _logger;
|
||||||
|
|
||||||
#region Ctor
|
#region Ctor
|
||||||
public SendTweetsToSharedInboxTask(IActivityPubService activityPubService, IStatusService statusService, IFollowersDal followersDal)
|
public SendTweetsToSharedInboxTask(IActivityPubService activityPubService, IStatusService statusService, IFollowersDal followersDal, ILogger<SendTweetsToSharedInboxTask> logger)
|
||||||
{
|
{
|
||||||
_activityPubService = activityPubService;
|
_activityPubService = activityPubService;
|
||||||
_statusService = statusService;
|
_statusService = statusService;
|
||||||
_followersDal = followersDal;
|
_followersDal = followersDal;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -47,8 +50,23 @@ namespace BirdsiteLive.Pipeline.Processors.SubTasks
|
||||||
{
|
{
|
||||||
foreach (var tweet in tweetsToSend)
|
foreach (var tweet in tweetsToSend)
|
||||||
{
|
{
|
||||||
var note = _statusService.GetStatus(user.Acct, tweet);
|
try
|
||||||
await _activityPubService.PostNewNoteActivity(note, user.Acct, tweet.Id.ToString(), host, inbox);
|
{
|
||||||
|
var note = _statusService.GetStatus(user.Acct, tweet);
|
||||||
|
await _activityPubService.PostNewNoteActivity(note, user.Acct, tweet.Id.ToString(), host, inbox);
|
||||||
|
}
|
||||||
|
catch (ArgumentException e)
|
||||||
|
{
|
||||||
|
if (e.Message.Contains("Invalid pattern") && e.Message.Contains("at offset")) //Regex exception
|
||||||
|
{
|
||||||
|
_logger.LogError(e, "Can't parse {MessageContent} from Tweet {Id}", tweet.MessageContent, tweet.Id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
syncStatus = tweet.Id;
|
syncStatus = tweet.Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue