aboutsummaryrefslogtreecommitdiff
path: root/post/util.go
diff options
context:
space:
mode:
authorFChannel <>2022-05-07 15:11:35 -0700
committerFChannel <>2022-06-19 12:53:29 -0700
commit3c5eebf6275e6d202f8a7b7f027aabcda5c1f332 (patch)
tree5fa2d82f9375ac49be357f0f8b70db06d5c97305 /post/util.go
parent39012c6b17073f6933a5ead8beed64df555f7348 (diff)
more organizing structs to have object functions
need to fully test to be sure nothing broke with changes
Diffstat (limited to 'post/util.go')
-rw-r--r--post/util.go14
1 files changed, 8 insertions, 6 deletions
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)
}