aboutsummaryrefslogtreecommitdiff
path: root/routes/admin.go
diff options
context:
space:
mode:
Diffstat (limited to 'routes/admin.go')
-rw-r--r--routes/admin.go50
1 files changed, 46 insertions, 4 deletions
diff --git a/routes/admin.go b/routes/admin.go
index 068dda3..528e40c 100644
--- a/routes/admin.go
+++ b/routes/admin.go
@@ -1,6 +1,11 @@
package routes
-import "github.com/gofiber/fiber/v2"
+import (
+ "github.com/FChannel0/FChannel-Server/config"
+ "github.com/FChannel0/FChannel-Server/db"
+ "github.com/FChannel0/FChannel-Server/webfinger"
+ "github.com/gofiber/fiber/v2"
+)
func AdminVerify(c *fiber.Ctx) error {
// STUB
@@ -14,10 +19,47 @@ func AdminAuth(c *fiber.Ctx) error {
return c.SendString("admin auth")
}
-func AdminIndex(c *fiber.Ctx) error {
- // STUB
+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 = db.Boards
+
+ adminData.Board.Post.Actor = actor.Id
+
+ adminData.PostBlacklist, _ = db.GetRegexBlacklistDB()
+
+ adminData.Themes = &config.Themes
- return c.SendString("admin index")
+ return ctx.Render("admin", fiber.Map{
+ "page": adminData,
+ })
}
func AdminAddBoard(c *fiber.Ctx) error {