aboutsummaryrefslogtreecommitdiff
path: root/routes/admin.go
blob: a2f7cd2b85cbb99097d98b79897d0dcb919b5069 (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
package routes

import (
	"github.com/FChannel0/FChannel-Server/config"
	"github.com/FChannel0/FChannel-Server/db"
	"github.com/FChannel0/FChannel-Server/util"
	"github.com/FChannel0/FChannel-Server/webfinger"
	"github.com/gofiber/fiber/v2"
)

func AdminVerify(c *fiber.Ctx) error {
	// STUB

	return c.SendString("admin verify")
}

func AdminAuth(c *fiber.Ctx) error {
	// STUB

	return c.SendString("admin auth")
}

func AdminIndex(ctx *fiber.Ctx) error {
	actor, err := webfinger.GetActor(config.Domain)

	if err != nil {
		return err
	}

	follow, _ := webfinger.GetActorCollection(actor.Following)
	follower, _ := webfinger.GetActorCollection(actor.Followers)

	var following []string
	var followers []string

	for _, e := range follow.Items {
		following = append(following, e.Id)
	}

	for _, e := range follower.Items {
		followers = append(followers, e.Id)
	}

	var adminData AdminPage
	adminData.Following = following
	adminData.Followers = followers
	adminData.Actor = actor.Id
	adminData.Key = config.Key
	adminData.Domain = config.Domain
	adminData.Board.ModCred, _ = db.GetPasswordFromSession(ctx)
	adminData.Title = actor.Name + " Admin page"

	adminData.Boards = webfinger.Boards

	adminData.Board.Post.Actor = actor.Id

	adminData.PostBlacklist, _ = util.GetRegexBlacklistDB()

	adminData.Themes = &config.Themes

	return ctx.Render("admin", fiber.Map{
		"page": adminData,
	})
}

func AdminAddBoard(c *fiber.Ctx) error {
	// STUB

	return c.SendString("admin add board")
}

func AdminPostNews(c *fiber.Ctx) error {
	// STUB

	return c.SendString("admin post news")
}

func AdminNewsDelete(c *fiber.Ctx) error {
	// STUB

	return c.SendString("admin news delete")
}