aboutsummaryrefslogtreecommitdiff
path: root/routes/admin.go
diff options
context:
space:
mode:
authorFChannel <>2022-04-24 00:46:49 -0700
committerFChannel <>2022-06-19 12:53:29 -0700
commit3db517715bef6a53225c5c3c06e8fc5fd0bf71e3 (patch)
tree9aa7fbcb12f2ec8d0e4e66cd85ace058e38dd32d /routes/admin.go
parent9718d34a757b66917747c1c4acfb9b35d154625b (diff)
basic pass over view posts, post, catalog and manage page connections
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 {