aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db/report.go28
-rw-r--r--route/routes/admin.go24
-rw-r--r--route/structs.go2
-rw-r--r--views/manage.html11
4 files changed, 34 insertions, 31 deletions
diff --git a/db/report.go b/db/report.go
index 958b619..f5569fd 100644
--- a/db/report.go
+++ b/db/report.go
@@ -5,9 +5,14 @@ import (
"github.com/FChannel0/FChannel-Server/util"
)
-type Report struct {
+type Reports struct {
ID string
Count int
+ Reason []string
+}
+
+type Report struct {
+ ID string
Reason string
}
@@ -72,10 +77,10 @@ func GetLocalDelete() ([]Removed, error) {
return deleted, nil
}
-func GetLocalReport(board string) ([]Report, error) {
- var reported []Report
+func GetLocalReport(board string) (map[string]Reports, error) {
+ var reported = make(map[string]Reports)
- query := `select id, count, reason from reported where board=$1`
+ query := `select id, reason from reported where board=$1`
rows, err := config.DB.Query(query, board)
if err != nil {
@@ -86,11 +91,22 @@ func GetLocalReport(board string) ([]Report, error) {
for rows.Next() {
var r Report
- if err := rows.Scan(&r.ID, &r.Count, &r.Reason); err != nil {
+ if err := rows.Scan(&r.ID, &r.Reason); err != nil {
return reported, util.MakeError(err, "GetLocalReportDB")
}
- reported = append(reported, r)
+ if report, has := reported[r.ID]; has {
+ report.Count += 1
+ report.Reason = append(report.Reason, r.Reason)
+ reported[r.ID] = report
+ continue
+ }
+
+ reported[r.ID] = Reports{
+ ID: r.ID,
+ Count: 1,
+ Reason: []string{r.Reason},
+ }
}
return reported, nil
diff --git a/route/routes/admin.go b/route/routes/admin.go
index 86e12c6..dfa7313 100644
--- a/route/routes/admin.go
+++ b/route/routes/admin.go
@@ -226,12 +226,8 @@ func AdminActorIndex(ctx *fiber.Ctx) error {
reqActivity.Id = actor.Followers
follower, _ := reqActivity.GetCollection()
- reqActivity.Id = actor.Id + "/reported"
- reported, _ := activitypub.GetActorCollectionReq(reqActivity.Id)
-
var following []string
var followers []string
- var reports []db.Report
for _, e := range follow.Items {
following = append(following, e.Id)
@@ -241,28 +237,10 @@ func AdminActorIndex(ctx *fiber.Ctx) error {
followers = append(followers, e.Id)
}
- for _, e := range reported.Items {
- var r db.Report
- r.Count = int(e.Size)
- r.ID = e.Id
- r.Reason = e.Content
- reports = append(reports, r)
- }
-
- localReports, _ := db.GetLocalReport(actor.Name)
-
- for _, e := range localReports {
- var r db.Report
- r.Count = e.Count
- r.ID = e.ID
- r.Reason = e.Reason
- reports = append(reports, r)
- }
-
var data route.AdminPage
data.Following = following
data.Followers = followers
- data.Reported = reports
+ data.Reported, _ = db.GetLocalReport(actor.Name)
data.Domain = config.Domain
data.IsLocal, _ = actor.IsLocal()
diff --git a/route/structs.go b/route/structs.go
index 7b1c2b8..fbfb327 100644
--- a/route/structs.go
+++ b/route/structs.go
@@ -37,7 +37,7 @@ type AdminPage struct {
Boards []webfinger.Board
Following []string
Followers []string
- Reported []db.Report
+ Reported map[string]db.Reports
Domain string
IsLocal bool
PostBlacklist []util.PostBlacklist
diff --git a/views/manage.html b/views/manage.html
index af887e3..356e09a 100644
--- a/views/manage.html
+++ b/views/manage.html
@@ -45,7 +45,16 @@
<ul style="display: inline-block; padding: 0; margin: 0; list-style-type: none;">
{{ $domain := .page.Domain }}
{{ range .page.Reported }}
- <li><a id="rpost" post="{{ .ID }}" href=""></a> - <b>{{ .Count }}</b><span> "{{ .Reason }}" </span> [<a href="/delete?id={{ .ID }}&board={{ $board.Name }}&manage=t">Remove Post</a>] [<a href="/deleteattach?id={{ .ID }}&board={{ $board.Name }}&manage=t">Remove Attachment</a>] [<a href="/report?id={{ .ID }}&close=1&board={{ $board.Name }}">Close</a>]</li>
+ <li>
+ <a id="rpost" post="{{ .ID }}" href="{{ $board.Actor.Id }}/{{ shortURL $board.Actor.Outbox .ID }}">{{ shortURL $board.Actor.Outbox .ID }}</a> - <b>{{ .Count }}</b> [<a href="/delete?id={{ .ID }}&board={{ $board.Name }}&manage=t">Remove Post</a>] [<a href="/deleteattach?id={{ .ID }}&board={{ $board.Name }}&manage=t">Remove Attachment</a>] [<a href="/report?id={{ .ID }}&close=1&board={{ $board.Name }}">Close</a>]
+ <ul>
+ {{ range .Reason }}
+ <li>
+ <span>"{{ . }}" </span>
+ </li>
+ {{ end }}
+ </ul>
+ </li>
{{ end }}
</ul>
</div>