From bc9051fd1a17e793647cf309c973a7feefebd98f Mon Sep 17 00:00:00 2001 From: KushBlazingJudah <59340248+KushBlazingJudah@users.noreply.github.com> Date: Tue, 2 Nov 2021 16:10:57 -0300 Subject: down to the main package it seems --- routes/index.go | 16 ++++++++++------ routes/structs.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ routes/util.go | 3 ++- 3 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 routes/structs.go (limited to 'routes') diff --git a/routes/index.go b/routes/index.go index df10d9f..a130796 100644 --- a/routes/index.go +++ b/routes/index.go @@ -3,11 +3,12 @@ package routes 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 Index(c *fiber.Ctx) error { - actor, err := db.GetActor(config.Domain) + actor, err := db.GetActorFromDB(config.Domain) if err != nil { return err } @@ -15,11 +16,11 @@ func Index(c *fiber.Ctx) error { var data PageData data.Title = "Welcome to " + actor.PreferredUsername data.PreferredUsername = actor.PreferredUsername - data.Boards = Boards + data.Boards = db.Boards data.Board.Name = "" - data.Key = *Key + data.Key = config.Key data.Board.Domain = config.Domain - data.Board.ModCred, _ = GetPasswordFromCtx(c) + data.Board.ModCred, _ = getPassword(c) data.Board.Actor = actor data.Board.Post.Actor = actor.Id data.Board.Restricted = actor.Restricted @@ -30,7 +31,10 @@ func Index(c *fiber.Ctx) error { data.BoardRemainer = make([]int, 0) } - col := GetCollectionFromReq("https://fchan.xyz/followers") + col, err := webfinger.GetCollectionFromReq("https://fchan.xyz/followers") + if err != nil { + return err + } if len(col.Items) > 0 { data.InstanceIndex = col.Items @@ -41,7 +45,7 @@ func Index(c *fiber.Ctx) error { return err } - data.Themes = &Themes + data.Themes = &config.Themes data.ThemeCookie = getThemeCookie(c) diff --git a/routes/structs.go b/routes/structs.go new file mode 100644 index 0000000..c145a6d --- /dev/null +++ b/routes/structs.go @@ -0,0 +1,45 @@ +package routes + +import ( + "github.com/FChannel0/FChannel-Server/activitypub" + "github.com/FChannel0/FChannel-Server/db" +) + +type PageData struct { + Title string + PreferredUsername string + Board db.Board + Pages []int + CurrentPage int + TotalPage int + Boards []db.Board + Posts []activitypub.ObjectBase + Key string + PostId string + Instance activitypub.Actor + InstanceIndex []activitypub.ObjectBase + ReturnTo string + NewsItems []db.NewsItem + BoardRemainer []int + + Themes *[]string + ThemeCookie string +} + +type AdminPage struct { + Title string + Board db.Board + Key string + Actor string + Boards []db.Board + Following []string + Followers []string + Reported []db.Report + Domain string + IsLocal bool + PostBlacklist []db.PostBlacklist + AutoSubscribe bool + + Themes *[]string + ThemeCookie string +} diff --git a/routes/util.go b/routes/util.go index 37639c3..a38e969 100644 --- a/routes/util.go +++ b/routes/util.go @@ -4,6 +4,7 @@ import ( "fmt" "strings" + "github.com/FChannel0/FChannel-Server/db" "github.com/gofiber/fiber/v2" ) @@ -22,7 +23,7 @@ func getPassword(r *fiber.Ctx) (string, string) { sessionToken := c - response, err := cache.Do("GET", sessionToken) + response, err := db.Cache.Do("GET", sessionToken) if err != nil { return "", "" } -- cgit v1.2.3