mirror of
https://github.com/github-tijlxyz/khatru-pyramid.git
synced 2025-06-06 18:31:02 +00:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5e9a09b3c5 | ||
![]() |
66e0c849fc | ||
![]() |
34ab0272c7 | ||
![]() |
c4a241a99f | ||
![]() |
cbc84a2004 |
28
handler.go
28
handler.go
@ -91,31 +91,3 @@ func reportsViewerHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
reportsPage(events, getLoggedUser(r)).Render(r.Context(), w)
|
||||
}
|
||||
|
||||
func joubleHandler(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, `
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyramid</title>
|
||||
<script>
|
||||
window.relayGroups = [{
|
||||
groupName: 'pyramid',
|
||||
relayUrls: [location.href.replace('http', 'ws').replace('/browse', '')],
|
||||
isActive: true,
|
||||
}]
|
||||
window.hideRelaySettings = true
|
||||
</script>
|
||||
<script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/jouble@0.0.6/dist/index.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/npm/jouble@0.0.6/dist/index.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/window.nostr.js@0.4.7/dist/window.nostr.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
`)
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ templ layout(loggedUser string) {
|
||||
</div>
|
||||
<nav class="flex flex-1 items-center justify-center">
|
||||
<a href="/" class="text-gray-600 hover:bg-gray-200 rounded-md px-3 py-2 font-medium" hx-boost="true" hx-target="main" hx-select="main">invite tree</a>
|
||||
<a href="/browse" class="text-gray-600 hover:bg-gray-200 rounded-md px-3 py-2 font-medium">browse</a>
|
||||
<a target="_blank" class="text-gray-600 hover:bg-gray-200 rounded-md px-3 py-2 font-medium" _="on load set my href to `https://jumble.social/?r=${location.hostname}`">browse</a>
|
||||
<a href="/reports" class="text-gray-600 hover:bg-gray-200 rounded-md px-3 py-2 font-medium" hx-boost="true" hx-target="main" hx-select="main">reports</a>
|
||||
if loggedUser == s.RelayPubkey {
|
||||
<a href="/cleanup" class="text-gray-600 hover:bg-gray-200 rounded-md px-3 py-2 font-medium">clear stuff</a>
|
||||
|
10
main.go
10
main.go
@ -9,6 +9,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/fiatjaf/eventstore/lmdb"
|
||||
"github.com/fiatjaf/khatru"
|
||||
@ -90,7 +91,13 @@ func main() {
|
||||
}
|
||||
relay.Info.Software = "https://github.com/github-tijlxyz/khatru-pyramid"
|
||||
|
||||
policies.ApplySaneDefaults(relay)
|
||||
relay.RejectFilter = append(relay.RejectFilter,
|
||||
policies.NoComplexFilters,
|
||||
policies.FilterIPRateLimiter(20, time.Minute, 100),
|
||||
)
|
||||
relay.RejectConnection = append(relay.RejectConnection,
|
||||
policies.ConnectionRateLimiter(1, time.Minute*5, 100),
|
||||
)
|
||||
|
||||
relay.StoreEvent = append(relay.StoreEvent, db.SaveEvent)
|
||||
relay.QueryEvents = append(relay.QueryEvents, db.QueryEvents)
|
||||
@ -128,7 +135,6 @@ func main() {
|
||||
relay.Router().HandleFunc("/remove-from-whitelist", removeFromWhitelistHandler)
|
||||
relay.Router().HandleFunc("/cleanup", cleanupStuffFromExcludedUsersHandler)
|
||||
relay.Router().HandleFunc("/reports", reportsViewerHandler)
|
||||
relay.Router().HandleFunc("/browse/", joubleHandler)
|
||||
relay.Router().Handle("/static/", http.FileServer(http.FS(static)))
|
||||
relay.Router().HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {
|
||||
if s.RelayIcon != "" {
|
||||
|
1
relay.go
1
relay.go
@ -68,6 +68,7 @@ var supportedKinds = []uint16{
|
||||
30015,
|
||||
30818,
|
||||
30819,
|
||||
30023,
|
||||
30030,
|
||||
30078,
|
||||
30311,
|
||||
|
@ -1,12 +1,13 @@
|
||||
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>
|
||||
<div class="max-w-4xl mx-auto">
|
||||
<h1 class="text-xl p-4">reports received</h1>
|
||||
<div>
|
||||
<div class="space-y-4 p-4">
|
||||
for report := range reports {
|
||||
<div>
|
||||
if e := report.Tags.Find("e"); e != nil {
|
||||
@ -23,28 +24,36 @@ templ reportsPage(reports chan *nostr.Event, loggedUser string) {
|
||||
|
||||
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 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>
|
||||
<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>
|
||||
{{ 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) {
|
||||
if isPublicKeyInWhitelist(p[1]) {
|
||||
<div>
|
||||
<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 {
|
||||
@ -53,14 +62,23 @@ templ profileReportComponent(p nostr.Tag, report *nostr.Event) {
|
||||
</span>
|
||||
{ " report" }
|
||||
</div>
|
||||
<div>by @userNameComponent(sys.FetchProfileMetadata(ctx, report.PubKey))</div>
|
||||
<div class="p-3">{ report.Content }</div>
|
||||
<div>
|
||||
profile reported:
|
||||
<a href={ templ.URL("https://njump.me/p/" + report.PubKey) } target="_blank" class="font-mono py-1">
|
||||
<nostr-name pubkey={ report.PubKey }>{ report.PubKey }</nostr-name>
|
||||
<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>
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user