[backend/federation] Iterate over paginated collections

This commit is contained in:
Kopper 2024-09-13 15:55:52 +03:00 committed by Laura Hausmann
parent 024de937d0
commit 5300aa069b
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
2 changed files with 15 additions and 1 deletions

View file

@ -90,5 +90,19 @@ public class ObjectResolver(
if (collection.Items != null) if (collection.Items != null)
foreach (var item in collection.Items) foreach (var item in collection.Items)
yield return item; 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;
}
} }
} }

View file

@ -14,7 +14,7 @@ public class ASObject : ASObjectBase
[JC(typeof(StringListSingleConverter))] [JC(typeof(StringListSingleConverter))]
public string? Type { get; set; } 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 //FIXME: don't recurse creates and co
public static ASObject? Deserialize(JToken token) public static ASObject? Deserialize(JToken token)