aboutsummaryrefslogtreecommitdiff
path: root/route/routes
diff options
context:
space:
mode:
authorFChannel <>2022-06-13 17:58:26 -0700
committerFChannel <>2022-06-19 12:53:29 -0700
commit5cff4d3740eb8b9f67de9713124e84109d04cff8 (patch)
tree8940203f84ef45e36d3cea414c40ace47152a8ce /route/routes
parentcc3e8e57154409469267b0526807a907d5166147 (diff)
admin reported management improvements
Diffstat (limited to 'route/routes')
-rw-r--r--route/routes/admin.go39
-rw-r--r--route/routes/api.go2
2 files changed, 37 insertions, 4 deletions
diff --git a/route/routes/admin.go b/route/routes/admin.go
index 1576a3a..a2b4ad5 100644
--- a/route/routes/admin.go
+++ b/route/routes/admin.go
@@ -6,6 +6,8 @@ import (
"errors"
"io/ioutil"
"net/http"
+ "regexp"
+ "sort"
"time"
"github.com/FChannel0/FChannel-Server/activitypub"
@@ -119,6 +121,24 @@ func AdminIndex(ctx *fiber.Ctx) error {
var adminData route.AdminPage
adminData.Following = following
adminData.Followers = followers
+
+ var reported = make(map[string][]db.Reports)
+
+ for _, e := range following {
+ re := regexp.MustCompile(`.*/(.+)$`)
+ boards := re.FindStringSubmatch(e)
+ reports, _ := db.GetLocalReport(boards[1])
+
+ for _, k := range reports {
+ reported[k.Actor.Name] = append(reported[k.Actor.Name], k)
+ }
+ }
+
+ for k, e := range reported {
+ sort.Sort(db.ReportsSortDesc(e))
+ reported[k] = e
+ }
+
adminData.Actor = actor.Id
adminData.Key = config.Key
adminData.Domain = config.Domain
@@ -140,7 +160,8 @@ func AdminIndex(ctx *fiber.Ctx) error {
adminData.Themes = &config.Themes
return ctx.Render("admin", fiber.Map{
- "page": adminData,
+ "page": adminData,
+ "reports": reported,
}, "layouts/main")
}
@@ -248,10 +269,21 @@ func AdminActorIndex(ctx *fiber.Ctx) error {
data.Following = following
data.Followers = followers
- data.Reported, _ = db.GetLocalReport(actor.Name)
+
+ reports, _ := db.GetLocalReport(actor.Name)
+
+ var reported = make(map[string][]db.Reports)
+ for _, k := range reports {
+ reported[k.Actor.Name] = append(reported[k.Actor.Name], k)
+ }
+
+ for k, e := range reported {
+ sort.Sort(db.ReportsSortDesc(e))
+ reported[k] = e
+ }
+
data.Domain = config.Domain
data.IsLocal, _ = actor.IsLocal()
-
data.Title = "Manage /" + actor.Name + "/"
data.Boards = webfinger.Boards
data.Board.Name = actor.Name
@@ -286,6 +318,7 @@ func AdminActorIndex(ctx *fiber.Ctx) error {
return ctx.Render("manage", fiber.Map{
"page": data,
"jannies": jannies,
+ "reports": reported,
}, "layouts/main")
}
diff --git a/route/routes/api.go b/route/routes/api.go
index 49c2623..70607e9 100644
--- a/route/routes/api.go
+++ b/route/routes/api.go
@@ -30,7 +30,7 @@ func RouteImages(ctx *fiber.Ctx, media string) error {
resp, err := client.Do(req)
if err != nil {
- return util.MakeError(err, "RouteImages")
+ return nil
}
defer resp.Body.Close()