mirror of
https://github.com/github-tijlxyz/khatru-pyramid.git
synced 2025-05-10 16:26:04 +00:00
85 lines
2.8 KiB
Plaintext
85 lines
2.8 KiB
Plaintext
package main
|
|
|
|
import "github.com/nbd-wtf/go-nostr"
|
|
import "github.com/nbd-wtf/go-nostr/nip19"
|
|
|
|
templ reportsPage(reports chan *nostr.Event, loggedUser string) {
|
|
@layout(loggedUser) {
|
|
<div class="max-w-4xl mx-auto">
|
|
<h1 class="text-xl p-4">reports received</h1>
|
|
<div class="space-y-4 p-4">
|
|
for report := range reports {
|
|
<div>
|
|
if e := report.Tags.Find("e"); e != nil {
|
|
@eventReportComponent(e, report)
|
|
} else if p := report.Tags.Find("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 class="bg-white rounded-lg shadow-sm border border-gray-200 p-4">
|
|
<div class="flex justify-between items-start">
|
|
<div class="font-lg">
|
|
<span class="font-semibold">
|
|
if len(e) >= 3 {
|
|
{ e[2] }
|
|
}
|
|
</span>
|
|
{ " report" }
|
|
</div>
|
|
<div class="text-sm text-gray-500">
|
|
{ report.CreatedAt.Time().Format("Jan 2, 2006 3:04 PM") }
|
|
</div>
|
|
</div>
|
|
{{ npub, _ := nip19.EncodePublicKey(report.PubKey) }}
|
|
<div class="mt-2 text-sm text-gray-600">by <a class="hover:underline" title={ report.PubKey } href={ templ.SafeURL("nostr:" + npub) }><nostr-name pubkey={ report.PubKey }></nostr-name></a></div>
|
|
if report.Content != "" {
|
|
<div class="mt-3 p-3 bg-gray-50 rounded">{ report.Content }</div>
|
|
}
|
|
<div class="mt-3">
|
|
<div class="text-sm text-gray-600">event reported:</div>
|
|
<div class="mt-1 font-mono text-sm bg-gray-50 p-2 rounded overflow-auto whitespace-pre-wrap break-all">{ res[0].String() }</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
}
|
|
|
|
templ profileReportComponent(p nostr.Tag, report *nostr.Event) {
|
|
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-4">
|
|
<div class="flex justify-between items-start">
|
|
<div class="font-lg">
|
|
<span class="font-semibold">
|
|
if len(p) >= 3 {
|
|
{ p[2] }
|
|
}
|
|
</span>
|
|
{ " report" }
|
|
</div>
|
|
<div class="text-sm text-gray-500">
|
|
{ report.CreatedAt.Time().Format("Jan 2, 2006 3:04 PM") }
|
|
</div>
|
|
</div>
|
|
{{ npub, _ := nip19.EncodePublicKey(report.PubKey) }}
|
|
<div class="mt-2 text-sm text-gray-600">by <a class="hover:underline" title={ report.PubKey } href={ templ.SafeURL("nostr:" + npub) }><nostr-name pubkey={ report.PubKey }></nostr-name></a></div>
|
|
if report.Content != "" {
|
|
<div class="mt-3 p-3 bg-gray-50 rounded">{ report.Content }</div>
|
|
}
|
|
<div class="mt-3">
|
|
<div class="text-sm text-gray-600">profile reported:</div>
|
|
<div class="mt-1">
|
|
{{ npubt, _ := nip19.EncodePublicKey(p[1]) }}
|
|
<a href={ templ.URL("nostr:" + npubt) } target="_blank" class="text-sm hover:underline">
|
|
<nostr-name pubkey={ p[1] }></nostr-name>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|