aboutsummaryrefslogtreecommitdiff
path: root/routes/post.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 /routes/post.go
parent39012c6b17073f6933a5ead8beed64df555f7348 (diff)
more organizing structs to have object functions
need to fully test to be sure nothing broke with changes
Diffstat (limited to 'routes/post.go')
-rw-r--r--routes/post.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/routes/post.go b/routes/post.go
index 1634346..ac722be 100644
--- a/routes/post.go
+++ b/routes/post.go
@@ -23,13 +23,14 @@ func PostGet(ctx *fiber.Ctx) error {
return nil
}
- postId := ctx.Params("post")
+ re := regexp.MustCompile("\\w+$")
+ postId := re.FindString(ctx.Path())
inReplyTo := actor.Id + "/" + postId
var data PageData
- re := regexp.MustCompile("f(\\w|[!@#$%^&*<>])+-(\\w|[!@#$%^&*<>])+")
+ re = regexp.MustCompile("f(\\w|[!@#$%^&*<>])+-(\\w|[!@#$%^&*<>])+")
if re.MatchString(ctx.Path()) { // if non local actor post
name := activitypub.GetActorFollowNameFromPath(ctx.Path())
@@ -56,18 +57,19 @@ func PostGet(ctx *fiber.Ctx) error {
data.Board.Post.Actor = actor.Id
}
} else {
- collection, err := activitypub.GetObjectByIDFromDB(inReplyTo)
+ obj := activitypub.ObjectBase{Id: inReplyTo}
+ collection, err := obj.GetCollectionFromPath()
if err != nil {
return err
}
- if collection.Actor != nil {
+ if collection.Actor.Id != "" {
data.Board.Post.Actor = collection.Actor.Id
data.Board.InReplyTo = inReplyTo
+ }
- if len(collection.OrderedItems) > 0 {
- data.Posts = append(data.Posts, collection.OrderedItems[0])
- }
+ if len(collection.OrderedItems) > 0 {
+ data.Posts = append(data.Posts, collection.OrderedItems[0])
}
}
@@ -124,7 +126,7 @@ func CatalogGet(ctx *fiber.Ctx) error {
return err
}
- collection, err := activitypub.GetObjectFromDBCatalog(actor.Id)
+ collection, err := actor.GetCatalogCollection()
// TODO: implement this in template functions
// "showArchive": func() bool {