diff options
author | FChannel <> | 2022-05-22 14:08:36 -0700 |
---|---|---|
committer | FChannel <> | 2022-06-19 12:53:29 -0700 |
commit | a66b676481d273508927e64a22e388dc302890ba (patch) | |
tree | 7c67b04dd8b39125526567ae6f08a39d0346d260 /routes/outbox.go | |
parent | 6a0f664b565716ad08301e7699d6c0393dbba977 (diff) |
route organization
Diffstat (limited to 'routes/outbox.go')
-rw-r--r-- | routes/outbox.go | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/routes/outbox.go b/routes/outbox.go deleted file mode 100644 index 1d0d52e..0000000 --- a/routes/outbox.go +++ /dev/null @@ -1,106 +0,0 @@ -package routes - -import ( - "strconv" - - "github.com/FChannel0/FChannel-Server/activitypub" - "github.com/FChannel0/FChannel-Server/config" - "github.com/FChannel0/FChannel-Server/post" - "github.com/FChannel0/FChannel-Server/util" - "github.com/FChannel0/FChannel-Server/webfinger" - "github.com/gofiber/fiber/v2" -) - -func Outbox(ctx *fiber.Ctx) error { - actor, err := webfinger.GetActorFromPath(ctx.Path(), "/") - if err != nil { - return util.MakeError(err, "Outbox") - } - - if activitypub.AcceptActivity(ctx.Get("Accept")) { - actor.GetOutbox(ctx) - return nil - } - - return ParseOutboxRequest(ctx, actor) -} - -func OutboxGet(ctx *fiber.Ctx) error { - actor, err := activitypub.GetActorByNameFromDB(ctx.Params("actor")) - - if err != nil { - return nil - } - - if activitypub.AcceptActivity(ctx.Get("Accept")) { - actor.GetInfoResp(ctx) - return nil - } - - var page int - if postNum := ctx.Query("page"); postNum != "" { - if page, err = strconv.Atoi(postNum); err != nil { - return util.MakeError(err, "OutboxGet") - } - } - - collection, err := actor.WantToServePage(page) - if err != nil { - return util.MakeError(err, "OutboxGet") - } - - var offset = 15 - var pages []int - pageLimit := (float64(collection.TotalItems) / float64(offset)) - - if pageLimit > 11 { - pageLimit = 11 - } - - for i := 0.0; i < pageLimit; i++ { - pages = append(pages, int(i)) - } - - var data PageData - data.Board.Name = actor.Name - data.Board.PrefName = actor.PreferredUsername - data.Board.Summary = actor.Summary - data.Board.InReplyTo = "" - data.Board.To = actor.Outbox - data.Board.Actor = actor - data.Board.ModCred, _ = util.GetPasswordFromSession(ctx) - data.Board.Domain = config.Domain - data.Board.Restricted = actor.Restricted - data.CurrentPage = page - data.ReturnTo = "feed" - - data.Board.Post.Actor = actor.Id - - capt, err := util.GetRandomCaptcha() - if err != nil { - return util.MakeError(err, "OutboxGet") - } - data.Board.Captcha = config.Domain + "/" + capt - data.Board.CaptchaCode = post.GetCaptchaCode(data.Board.Captcha) - - data.Title = "/" + actor.Name + "/ - " + actor.PreferredUsername - - data.Key = config.Key - - data.Boards = webfinger.Boards - data.Posts = collection.OrderedItems - - data.Pages = pages - data.TotalPage = len(data.Pages) - 1 - - data.Meta.Description = data.Board.Summary - data.Meta.Url = data.Board.Actor.Id - data.Meta.Title = data.Title - - data.Themes = &config.Themes - data.ThemeCookie = getThemeCookie(ctx) - - return ctx.Render("nposts", fiber.Map{ - "page": data, - }, "layouts/main") -} |