[backend/core] Catch errors in NoteService.ResolveNoteAsync

This fixes some inbox job failures, for example when a post quoting a deleted post is being ingested.
This commit is contained in:
Laura Hausmann 2024-10-06 14:04:06 +02:00
parent b5ad7649ea
commit 0962b07021
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
2 changed files with 12 additions and 1 deletions

View file

@ -185,7 +185,7 @@ public class ActivityFetcherService(
if (!response.IsSuccessStatusCode)
{
if (response.StatusCode == HttpStatusCode.Gone)
throw AuthFetchException.NotFound("The remote user no longer exists.");
throw AuthFetchException.NotFound("The remote object no longer exists.");
logger.LogDebug("Failed to fetch activity: response status was {code}", response.StatusCode);
return null;
}

View file

@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System.Net;
using AsyncKeyedLock;
using Iceshrimp.Backend.Core.Configuration;
using Iceshrimp.Backend.Core.Database;
@ -1141,6 +1142,16 @@ public class NoteService(
var id = e.Uri[$"https://{config.Value.WebDomain}/notes/".Length..];
return await db.Notes.IncludeCommonProperties().FirstOrDefaultAsync(p => p.Id == id);
}
catch (AuthFetchException e) when (e.StatusCode == HttpStatusCode.NotFound)
{
logger.LogDebug("Failed to fetch note, skipping: {error}", e.Message);
return null;
}
catch (Exception e)
{
logger.LogDebug("Failed to fetch note, skipping: {error}", e);
return null;
}
if (fetchedNote == null)
{