aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--activitypub/actor.go2
-rw-r--r--main.go11
-rw-r--r--route/routes/actor.go27
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")
diff --git a/main.go b/main.go
index 3efb9ff..d362244 100644
--- a/main.go
+++ b/main.go
@@ -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
+}