From 3c5eebf6275e6d202f8a7b7f027aabcda5c1f332 Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Sat, 7 May 2022 15:11:35 -0700 Subject: more organizing structs to have object functions need to fully test to be sure nothing broke with changes --- post/util.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'post') diff --git a/post/util.go b/post/util.go index b9d9b80..b27a208 100644 --- a/post/util.go +++ b/post/util.go @@ -248,7 +248,7 @@ func ObjectFromForm(ctx *fiber.Ctx, obj activitypub.ObjectBase) (activitypub.Obj } } - obj.Preview = activitypub.CreatePreviewObject(obj.Attachment[0]) + obj.Preview = obj.Attachment[0].CreatePreview() } obj.AttributedTo = util.EscapeString(ctx.FormValue("name")) @@ -368,10 +368,11 @@ func ResizeAttachmentToPreview() error { if err := cmd.Run(); err == nil { fmt.Println(objFile + " -> " + nHref) - if err := activitypub.WritePreviewToDB(nPreview); err != nil { + if err := nPreview.WritePreview(); err != nil { return err } - if err := activitypub.UpdateObjectWithPreview(id, nPreview.Id); err != nil { + obj := activitypub.ObjectBase{Id: id} + if err := obj.UpdatePreview(nPreview.Id); err != nil { return err } } else { @@ -510,13 +511,14 @@ func ParseLinkComments(board activitypub.Actor, op string, content string, threa } if quoteTitle == "" { - obj, err := activitypub.GetObjectFromDBFromID(parsedLink) + obj := activitypub.ObjectBase{Id: parsedLink} + col, err := obj.GetCollectionFromPath() if err != nil { return "", err } - if len(obj.OrderedItems) > 0 { - quoteTitle = ParseLinkTitle(board.Outbox, op, obj.OrderedItems[0].Content) + if len(col.OrderedItems) > 0 { + quoteTitle = ParseLinkTitle(board.Outbox, op, col.OrderedItems[0].Content) } else { quoteTitle = ParseLinkTitle(board.Outbox, op, parsedLink) } -- cgit v1.2.3