aboutsummaryrefslogtreecommitdiff
path: root/routes/index.go
diff options
context:
space:
mode:
authorFChannel <>2022-05-08 14:57:40 -0700
committerFChannel <>2022-06-19 12:53:29 -0700
commit580dec5b89215310ce34341e11ff17fe38bdb63a (patch)
tree894424df66a9d9f7e41805822f29adac8fb490fe /routes/index.go
parentf7bf818d29393ceaccf4d2906557351fa6a4f49f (diff)
more cleanup, logging and error logging everywhere
things are mostly in place can work on "features" and polish
Diffstat (limited to 'routes/index.go')
-rw-r--r--routes/index.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/routes/index.go b/routes/index.go
index 8f12664..68fcfd0 100644
--- a/routes/index.go
+++ b/routes/index.go
@@ -4,6 +4,7 @@ import (
"github.com/FChannel0/FChannel-Server/activitypub"
"github.com/FChannel0/FChannel-Server/config"
"github.com/FChannel0/FChannel-Server/db"
+ "github.com/FChannel0/FChannel-Server/util"
"github.com/FChannel0/FChannel-Server/webfinger"
"github.com/gofiber/fiber/v2"
)
@@ -11,7 +12,7 @@ import (
func Index(ctx *fiber.Ctx) error {
actor, err := activitypub.GetActorFromDB(config.Domain)
if err != nil {
- return err
+ return util.MakeError(err, "Index")
}
// this is a activitpub json request return json instead of html page
@@ -22,18 +23,19 @@ func Index(ctx *fiber.Ctx) error {
var data PageData
- col, err := webfinger.GetCollectionFromReq("https://fchan.xyz/followers")
+ reqActivity := activitypub.Activity{Id: "https://fchan.xyz/followers"}
+ col, err := reqActivity.GetCollection()
if err != nil {
- return err
+ return util.MakeError(err, "Index")
}
if len(col.Items) > 0 {
data.InstanceIndex = col.Items
}
- data.NewsItems, err = db.GetNewsFromDB(3)
+ data.NewsItems, err = db.GetNews(3)
if err != nil {
- return err
+ return util.MakeError(err, "Index")
}
data.Title = "Welcome to " + actor.PreferredUsername
@@ -42,7 +44,7 @@ func Index(ctx *fiber.Ctx) error {
data.Board.Name = ""
data.Key = config.Key
data.Board.Domain = config.Domain
- data.Board.ModCred, _ = db.GetPasswordFromSession(ctx)
+ data.Board.ModCred, _ = util.GetPasswordFromSession(ctx)
data.Board.Actor = actor
data.Board.Post.Actor = actor.Id
data.Board.Restricted = actor.Restricted