aboutsummaryrefslogtreecommitdiff
path: root/routes/outbox.go
diff options
context:
space:
mode:
authorKushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com>2021-11-07 00:32:39 -0300
committerFChannel <>2022-06-19 12:53:29 -0700
commit972223c992ca5aa5e5d93cff3b2ee4e30182025b (patch)
treeff61695c734852aeafdc0e872cc6f47085a8e787 /routes/outbox.go
parentbc9051fd1a17e793647cf309c973a7feefebd98f (diff)
restructuring part 5
Diffstat (limited to 'routes/outbox.go')
-rw-r--r--routes/outbox.go83
1 files changed, 80 insertions, 3 deletions
diff --git a/routes/outbox.go b/routes/outbox.go
index 8945bb1..b00f946 100644
--- a/routes/outbox.go
+++ b/routes/outbox.go
@@ -1,9 +1,86 @@
package routes
-import "github.com/gofiber/fiber/v2"
+import (
+ "strconv"
-func Outbox(c *fiber.Ctx) error {
+ "github.com/FChannel0/FChannel-Server/config"
+ "github.com/FChannel0/FChannel-Server/db"
+ "github.com/FChannel0/FChannel-Server/util"
+ "github.com/gofiber/fiber/v2"
+)
+
+func Outbox(ctx *fiber.Ctx) error {
// STUB
- return c.SendString("main outbox")
+ return ctx.SendString("main outbox")
+}
+
+func OutboxGet(ctx *fiber.Ctx) error {
+ collection, valid, err := wantToServePage(ctx.Params("actor"), 0)
+ if err != nil {
+ return err
+ } else if !valid {
+ // TODO: 404 template
+ return ctx.SendString("404")
+ }
+
+ actor := collection.Actor
+
+ postNum := ctx.Query("page")
+ page, err := strconv.Atoi(postNum)
+ if err != nil {
+ return err
+ }
+
+ var returnData PageData
+
+ returnData.Board.Name = actor.Name
+ returnData.Board.PrefName = actor.PreferredUsername
+ returnData.Board.Summary = actor.Summary
+ returnData.Board.InReplyTo = ""
+ returnData.Board.To = actor.Outbox
+ returnData.Board.Actor = *actor
+ returnData.Board.ModCred, _ = getPassword(ctx)
+ returnData.Board.Domain = config.Domain
+ returnData.Board.Restricted = actor.Restricted
+ returnData.CurrentPage = page
+ returnData.ReturnTo = "feed"
+
+ returnData.Board.Post.Actor = actor.Id
+
+ capt, err := db.GetRandomCaptcha()
+ if err != nil {
+ return err
+ }
+ returnData.Board.Captcha = config.Domain + "/" + capt
+ returnData.Board.CaptchaCode = util.GetCaptchaCode(returnData.Board.Captcha)
+
+ returnData.Title = "/" + actor.Name + "/ - " + actor.PreferredUsername
+
+ returnData.Key = config.Key
+
+ returnData.Boards = db.Boards
+ returnData.Posts = collection.OrderedItems
+
+ 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))
+ }
+
+ returnData.Pages = pages
+ returnData.TotalPage = len(returnData.Pages) - 1
+
+ returnData.Themes = &config.Themes
+ returnData.ThemeCookie = getThemeCookie(ctx)
+
+ return ctx.Render("nposts", fiber.Map{
+ "page": returnData,
+ }, "layouts/main")
}