aboutsummaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
Diffstat (limited to 'routes')
-rw-r--r--routes/index.go16
-rw-r--r--routes/structs.go45
-rw-r--r--routes/util.go3
3 files changed, 57 insertions, 7 deletions
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 "", ""
}