From 3db517715bef6a53225c5c3c06e8fc5fd0bf71e3 Mon Sep 17 00:00:00 2001 From: FChannel <> Date: Sun, 24 Apr 2022 00:46:49 -0700 Subject: basic pass over view posts, post, catalog and manage page connections --- routes/admin.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) (limited to 'routes/admin.go') 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 { -- cgit v1.2.3