From 5300aa069b946a7675df26581c296f37e4e42786 Mon Sep 17 00:00:00 2001 From: Kopper Date: Fri, 13 Sep 2024 15:55:52 +0300 Subject: [PATCH] [backend/federation] Iterate over paginated collections --- .../Core/Federation/ActivityPub/ObjectResolver.cs | 14 ++++++++++++++ .../Federation/ActivityStreams/Types/ASObject.cs | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Iceshrimp.Backend/Core/Federation/ActivityPub/ObjectResolver.cs b/Iceshrimp.Backend/Core/Federation/ActivityPub/ObjectResolver.cs index bd36b674..a2c5d790 100644 --- a/Iceshrimp.Backend/Core/Federation/ActivityPub/ObjectResolver.cs +++ b/Iceshrimp.Backend/Core/Federation/ActivityPub/ObjectResolver.cs @@ -90,5 +90,19 @@ public class ObjectResolver( if (collection.Items != null) foreach (var item in collection.Items) yield return item; + + var page = collection.First; + while (page != null) + { + if (page.IsUnresolved) + page = await ResolveObject(page, force: true) as ASCollectionPage; + if (page == null) break; + + if (page.Items != null) + foreach (var item in page.Items) + yield return item; + + page = page.Next; + } } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Federation/ActivityStreams/Types/ASObject.cs b/Iceshrimp.Backend/Core/Federation/ActivityStreams/Types/ASObject.cs index e6861564..0eefb1bc 100644 --- a/Iceshrimp.Backend/Core/Federation/ActivityStreams/Types/ASObject.cs +++ b/Iceshrimp.Backend/Core/Federation/ActivityStreams/Types/ASObject.cs @@ -14,7 +14,7 @@ public class ASObject : ASObjectBase [JC(typeof(StringListSingleConverter))] public string? Type { get; set; } - [JI] public bool IsUnresolved => GetType() == typeof(ASObject) && Type == null; + [JI] public bool IsUnresolved => this is ASObject && Type == null; //FIXME: don't recurse creates and co public static ASObject? Deserialize(JToken token)