diff --git a/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityFetcherService.cs b/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityFetcherService.cs index 4f0709a4..346e31d2 100644 --- a/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityFetcherService.cs +++ b/Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityFetcherService.cs @@ -9,7 +9,12 @@ using Newtonsoft.Json.Linq; namespace Iceshrimp.Backend.Core.Federation.ActivityPub; -public class ActivityFetcherService(HttpClient client, HttpRequestService httpRqSvc, SystemUserService systemUserSvc) +public class ActivityFetcherService( + HttpClient client, + HttpRequestService httpRqSvc, + SystemUserService systemUserSvc, + ILogger logger +) { private static readonly IReadOnlyCollection AcceptableActivityTypes = [ @@ -31,9 +36,18 @@ public class ActivityFetcherService(HttpClient client, HttpRequestService httpRq var request = httpRqSvc.GetSigned(url, AcceptableActivityTypes, actor, keypair); var response = await client.SendAsync(request); - if (!response.IsSuccessStatusCode) return []; - if (!IsValidActivityContentType(response.Content.Headers.ContentType)) + if (!response.IsSuccessStatusCode) + { + logger.LogDebug("Failed to fetch activity: response status was {code}", response.StatusCode); return []; + } + + if (!IsValidActivityContentType(response.Content.Headers.ContentType)) + { + logger.LogDebug("Failed to fetch activity: content type {type} is invalid", + response.Content.Headers.ContentType); + return []; + } var finalUri = response.RequestMessage?.RequestUri ?? throw new Exception("RequestMessage must not be null at this stage"); diff --git a/Iceshrimp.Backend/Core/Services/NoteService.cs b/Iceshrimp.Backend/Core/Services/NoteService.cs index 8d9e484a..31870fad 100644 --- a/Iceshrimp.Backend/Core/Services/NoteService.cs +++ b/Iceshrimp.Backend/Core/Services/NoteService.cs @@ -526,7 +526,12 @@ public class NoteService( //TODO: should we fall back to a regular user's keypair if fetching with instance actor fails & a local user is following the actor? fetchedNote ??= await fetchSvc.FetchNoteAsync(uri); - if (fetchedNote?.AttributedTo is not [{ Id: not null } attrTo]) + if (fetchedNote == null) + { + logger.LogDebug("Failed to fetch note, skipping"); + return null; + } + if (fetchedNote.AttributedTo is not [{ Id: not null } attrTo]) { logger.LogDebug("Invalid Note.AttributedTo, skipping"); return null;