From 5ca02e417cb5e60b020c0e090ac56d1000aed1cd Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Sun, 6 Jun 2021 00:07:31 -0700 Subject: correct post ordering when following instance --- cacheDatabase.go | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'cacheDatabase.go') diff --git a/cacheDatabase.go b/cacheDatabase.go index 380ade0..390e98e 100644 --- a/cacheDatabase.go +++ b/cacheDatabase.go @@ -30,6 +30,32 @@ func WriteObjectToCache(db *sql.DB, obj ObjectBase) ObjectBase { return obj } +func WriteActorObjectToCache(db *sql.DB, obj ObjectBase) ObjectBase { + if len(obj.Attachment) > 0 { + if obj.Preview.Href != "" { + WritePreviewToCache(db, *obj.Preview) + } + + for i, _ := range obj.Attachment { + WriteAttachmentToCache(db, obj.Attachment[i]) + WriteActivitytoCacheWithAttachment(db, obj, obj.Attachment[i], *obj.Preview) + } + + } else { + WriteActivitytoCache(db, obj) + } + + WriteActorObjectReplyToDB(db, obj) + + if obj.Replies != nil { + for _, e := range obj.Replies.OrderedItems { + WriteActorObjectToCache(db, e) + } + } + + return obj +} + func WriteActivitytoCache(db *sql.DB, obj ObjectBase) { obj.Name = EscapeString(obj.Name) @@ -232,7 +258,7 @@ func WriteActorToCache(db *sql.DB, actorID string) { collection := GetActorCollection(actor.Outbox) for _, e := range collection.OrderedItems { - WriteObjectToCache(db, e) + WriteActorObjectToCache(db, e) } } -- cgit v1.2.3