blob: b00f946c90bb8f28d2449faee3a28ba2a58d566c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
package routes
import (
"strconv"
"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 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")
}
|