-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathreports.templ
64 lines (60 loc) · 1.54 KB
/
reports.templ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import "github.com/nbd-wtf/go-nostr"
templ reportsPage(reports chan *nostr.Event, loggedUser string) {
@layout(loggedUser) {
<div>
<h1 class="text-xl p-4">reports received</h1>
<div>
for report := range reports {
<div>
if e := report.Tags.GetFirst([]string{"e", ""}); e != nil {
@eventReportComponent(e, report)
} else if p := report.Tags.GetFirst([]string{"p", ""}); p != nil {
@profileReportComponent(p, report)
}
</div>
}
</div>
</div>
}
}
templ eventReportComponent(e *nostr.Tag, report *nostr.Event) {
if res, _ := sys.StoreRelay.QuerySync(ctx, nostr.Filter{IDs: []string{(*e)[1]}}); len(res) > 0 {
<div>
<div class="font-lg">
<span class="font-semibold">
if len(*e) >= 3 {
{ (*e)[2] }
}
</span>
{ " report" }
</div>
<div>by @userNameComponent(sys.FetchProfileMetadata(ctx, report.PubKey))</div>
<div class="p-3">{ report.Content }</div>
<div>
event reported:
<div class="text-mono">{ res[0].String() }</div>
</div>
</div>
}
}
templ profileReportComponent(p *nostr.Tag, report *nostr.Event) {
if isPublicKeyInWhitelist((*p)[1]) {
<div>
<div class="font-lg">
<span class="font-semibold">
if len(*p) >= 3 {
{ (*p)[2] }
}
</span>
{ " report" }
</div>
<div>by @userNameComponent(sys.FetchProfileMetadata(ctx, report.PubKey))</div>
<div class="p-3">{ report.Content }</div>
<div>
profile reported:
@userNameComponent(sys.FetchProfileMetadata(ctx, (*p)[1]))
</div>
</div>
}
}