[backend/federation] Don't require ASNotes by the authenticated actor to be fetchable
This fixes e.g. renotes of follower-only posts
This commit is contained in:
parent
fee5296cd9
commit
75b2227524
2 changed files with 19 additions and 7 deletions
|
@ -21,7 +21,6 @@ public class ActivityHandlerService(
|
|||
DatabaseContext db,
|
||||
IOptions<Config.InstanceSection> config,
|
||||
FederationControlService federationCtrl,
|
||||
ObjectResolver resolver,
|
||||
NotificationService notificationSvc,
|
||||
ObjectResolver objectResolver,
|
||||
FollowupTaskService followupTaskSvc,
|
||||
|
@ -56,7 +55,7 @@ public class ActivityHandlerService(
|
|||
|
||||
// Resolve object & children
|
||||
if (activity.Object != null)
|
||||
activity.Object = await resolver.ResolveObject(activity.Object) ??
|
||||
activity.Object = await objectResolver.ResolveObject(activity.Object, resolvedActor.Uri) ??
|
||||
throw GracefulException.UnprocessableEntity("Failed to resolve activity object");
|
||||
|
||||
//TODO: validate inboxUserId
|
||||
|
@ -203,7 +202,7 @@ public class ActivityHandlerService(
|
|||
}
|
||||
case ASBite bite:
|
||||
{
|
||||
var target = await objectResolver.ResolveObject(bite.Target);
|
||||
var target = await objectResolver.ResolveObject(bite.Target, resolvedActor.Uri);
|
||||
var dbBite = target switch
|
||||
{
|
||||
ASActor targetActor => new Bite
|
||||
|
|
|
@ -14,18 +14,31 @@ public class ObjectResolver(
|
|||
IOptions<Config.InstanceSection> config
|
||||
)
|
||||
{
|
||||
public async Task<ASObject?> ResolveObject(ASObjectBase baseObj, int recurse = 5, bool force = false)
|
||||
public async Task<ASObject?> ResolveObject(
|
||||
ASObjectBase baseObj, string? actorUri = null, int recurse = 5, bool force = false
|
||||
)
|
||||
{
|
||||
logger.LogDebug("Resolving object: {id}", baseObj.Id ?? "<anonymous>");
|
||||
|
||||
if (baseObj is ASActivity { Object.IsUnresolved: true } activity && recurse > 0)
|
||||
{
|
||||
activity.Object = await ResolveObject(activity.Object, --recurse, force);
|
||||
return await ResolveObject(activity, recurse);
|
||||
activity.Object = await ResolveObject(activity.Object, actorUri, --recurse, force);
|
||||
return await ResolveObject(activity, actorUri, recurse);
|
||||
}
|
||||
|
||||
if (baseObj is ASObject { IsUnresolved: false } obj && !force)
|
||||
{
|
||||
if (actorUri == null ||
|
||||
baseObj is not ASNote { AttributedTo.Count: > 0 } note ||
|
||||
note.AttributedTo.Any(p => p.Id != actorUri))
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
|
||||
note.VerifiedFetch = true;
|
||||
return note;
|
||||
}
|
||||
|
||||
if (baseObj.Id == null)
|
||||
{
|
||||
logger.LogDebug("Refusing to resolve object with null id property");
|
||||
|
|
Loading…
Add table
Reference in a new issue