diff options
author | FChannel <> | 2022-06-16 12:39:41 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | aebf10de3b631f452600a5b31c1f43c1bbf8bdf2 (patch) | |
tree | 6d8855a96a0c3188df015e1b8c54e1db3db00a75 | |
parent | 44a5de2ecef3cba0d4d596f86183e7fd383615c0 (diff) |
fixed query to actor/outbox
-rw-r--r-- | activitypub/actor.go | 2 | ||||
-rw-r--r-- | main.go | 11 | ||||
-rw-r--r-- | route/routes/actor.go | 27 |
3 files changed, 30 insertions, 10 deletions
diff --git a/activitypub/actor.go b/activitypub/actor.go index be51460..9996abd 100644 --- a/activitypub/actor.go +++ b/activitypub/actor.go @@ -594,7 +594,7 @@ func (actor Actor) GetFollowersResp(ctx *fiber.Ctx) error { following.AtContext.Context = "https://www.w3.org/ns/activitystreams" following.Type = "Collection" - following.TotalItems, err = actor.GetFollowingTotal() + following.TotalItems, err = actor.GetFollowersTotal() if err != nil { return util.MakeError(err, "GetFollowersResp") @@ -93,15 +93,16 @@ func main() { app.Get("/api/media", routes.Media) // Board actor routes - app.Post("/post", routes.ActorPost) + app.Post("/post", routes.MakeActorPost) app.Get("/:actor/catalog", routes.ActorCatalog) app.Post("/:actor/inbox", routes.ActorInbox) - app.All("/:actor/outbox", routes.ActorOutbox) + app.Get("/:actor/outbox", routes.GetActorOutbox) + app.Post("/:actor/outbox", routes.PostActorOutbox) app.Get("/:actor/following", routes.ActorFollowing) - app.All("/:actor/followers", routes.ActorFollowers) + app.Get("/:actor/followers", routes.ActorFollowers) app.Get("/:actor/archive", routes.ActorArchive) - app.Get("/:actor", routes.ActorOutboxGet) - app.Get("/:actor/:post", routes.ActorPostGet) + app.Get("/:actor", routes.ActorPosts) + app.Get("/:actor/:post", routes.ActorPost) db.PrintAdminAuth() diff --git a/route/routes/actor.go b/route/routes/actor.go index 8690b78..f5bfb4c 100644 --- a/route/routes/actor.go +++ b/route/routes/actor.go @@ -2,6 +2,7 @@ package routes import ( "bytes" + "encoding/json" "io" "io/ioutil" "mime/multipart" @@ -170,7 +171,7 @@ func ActorInbox(ctx *fiber.Ctx) error { return nil } -func ActorOutbox(ctx *fiber.Ctx) error { +func PostActorOutbox(ctx *fiber.Ctx) error { //var activity activitypub.Activity actor, err := webfinger.GetActorFromPath(ctx.Path(), "/") if err != nil { @@ -195,7 +196,7 @@ func ActorFollowers(ctx *fiber.Ctx) error { return actor.GetFollowersResp(ctx) } -func ActorPost(ctx *fiber.Ctx) error { +func MakeActorPost(ctx *fiber.Ctx) error { header, _ := ctx.FormFile("file") if ctx.FormValue("inReplyTo") == "" && header == nil { @@ -356,7 +357,7 @@ func ActorPost(ctx *fiber.Ctx) error { return ctx.Redirect(config.Domain+"/"+ctx.FormValue("boardName"), 301) } -func ActorPostGet(ctx *fiber.Ctx) error { +func ActorPost(ctx *fiber.Ctx) error { actor, err := activitypub.GetActorByNameFromDB(ctx.Params("actor")) if err != nil { @@ -533,7 +534,7 @@ func ActorCatalog(ctx *fiber.Ctx) error { }, "layouts/main") } -func ActorOutboxGet(ctx *fiber.Ctx) error { +func ActorPosts(ctx *fiber.Ctx) error { actor, err := activitypub.GetActorByNameFromDB(ctx.Params("actor")) if err != nil { @@ -669,3 +670,21 @@ func ActorArchive(ctx *fiber.Ctx) error { "page": returnData, }, "layouts/main") } + +func GetActorOutbox(ctx *fiber.Ctx) error { + actor, _ := webfinger.GetActorFromPath(ctx.Path(), "/") + + collection, _ := actor.GetCollection() + collection.AtContext.Context = "https://www.w3.org/ns/activitystreams" + collection.Actor = actor + + collection.TotalItems, _ = actor.GetPostTotal() + collection.TotalImgs, _ = actor.GetImgTotal() + + enc, _ := json.Marshal(collection) + + ctx.Response().Header.Add("Content-Type", config.ActivityStreams) + _, err := ctx.Write(enc) + + return err +} |