better logging
This commit is contained in:
parent
467135e41f
commit
84b0da5093
1 changed files with 29 additions and 18 deletions
|
@ -9,6 +9,7 @@ using BirdsiteLive.ActivityPub;
|
||||||
using BirdsiteLive.ActivityPub.Converters;
|
using BirdsiteLive.ActivityPub.Converters;
|
||||||
using BirdsiteLive.ActivityPub.Models;
|
using BirdsiteLive.ActivityPub.Models;
|
||||||
using BirdsiteLive.Common.Settings;
|
using BirdsiteLive.Common.Settings;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Org.BouncyCastle.Bcpg;
|
using Org.BouncyCastle.Bcpg;
|
||||||
|
|
||||||
|
@ -27,13 +28,15 @@ namespace BirdsiteLive.Domain
|
||||||
private readonly InstanceSettings _instanceSettings;
|
private readonly InstanceSettings _instanceSettings;
|
||||||
private readonly IHttpClientFactory _httpClientFactory;
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
private readonly ICryptoService _cryptoService;
|
private readonly ICryptoService _cryptoService;
|
||||||
|
private readonly ILogger<ActivityPubService> _logger;
|
||||||
|
|
||||||
#region Ctor
|
#region Ctor
|
||||||
public ActivityPubService(ICryptoService cryptoService, InstanceSettings instanceSettings, IHttpClientFactory httpClientFactory)
|
public ActivityPubService(ICryptoService cryptoService, InstanceSettings instanceSettings, IHttpClientFactory httpClientFactory, ILogger<ActivityPubService> logger)
|
||||||
{
|
{
|
||||||
_cryptoService = cryptoService;
|
_cryptoService = cryptoService;
|
||||||
_instanceSettings = instanceSettings;
|
_instanceSettings = instanceSettings;
|
||||||
_httpClientFactory = httpClientFactory;
|
_httpClientFactory = httpClientFactory;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -47,6 +50,8 @@ namespace BirdsiteLive.Domain
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task PostNewNoteActivity(Note note, string username, string noteId, string targetHost, string targetInbox)
|
public async Task PostNewNoteActivity(Note note, string username, string noteId, string targetHost, string targetInbox)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var actor = UrlFactory.GetActorUrl(_instanceSettings.Domain, username);
|
var actor = UrlFactory.GetActorUrl(_instanceSettings.Domain, username);
|
||||||
var noteUri = UrlFactory.GetNoteUrl(_instanceSettings.Domain, username, noteId);
|
var noteUri = UrlFactory.GetNoteUrl(_instanceSettings.Domain, username, noteId);
|
||||||
|
@ -69,6 +74,12 @@ namespace BirdsiteLive.Domain
|
||||||
|
|
||||||
await PostDataAsync(noteActivity, targetHost, actor, targetInbox);
|
await PostDataAsync(noteActivity, targetHost, actor, targetInbox);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.LogError(e, "Error sending {Username} post ({NoteId}) to {Host}{Inbox}", username, noteId, targetHost, targetInbox);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<HttpStatusCode> PostDataAsync<T>(T data, string targetHost, string actorUrl, string inbox = null)
|
public async Task<HttpStatusCode> PostDataAsync<T>(T data, string targetHost, string actorUrl, string inbox = null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue