clone

nostr relays on demand at <name>.bind.ws: claim one with your key, pay in zaps past the free allowance

manage: listeventsneedingmoderation over the reports queue

Dami committed f4acbb6
One entry per open reported thing, an event id or a blob hash, with the
report's type and words as the reason. Owner and moderator, like the rest
of the reports actions.
commit
f4acbb6df774004b9a47c7e6b28a0a4936d49696
parent
bba0a8cb4590e1ccdbe46e439da276e1a76ef225
author
Dami <dami.etoile@gmail.com>
2 files changed, +14 -2
Msrc/manage.ts14+++++++++++++-
Msrc/roles.ts2+-
M src/manage.ts +13 -1
@@ -50,7 +50,7 @@ const METHODS = [
5050 "allowkind", "disallowkind", "unrulekind", "listallowedkinds", "listblockedkinds",5151 "changerelayname", "changerelaydescription", "changerelayicon",5252 "createinvite", "listinvites", "revokeinvite", "listmembers",53- "listreports", "resolvereport",53+ "listreports", "resolvereport", "listeventsneedingmoderation",5454 "listblobs", "deleteblob",5555 "storagestats", "setretention", "listretention", "purgekind",5656 "deleterelay", "exportconfig", "importconfig", "resetrules",
@@ -195,6 +195,18 @@ export async function manage(relay: Relay, req: Request): Promise<Response> {
195195 case "allowevent":196196 s.setEvent(str(0), null);197197 return reply({ result: true });198+ case "listeventsneedingmoderation": {199+ // NIP-86's view of the reports queue: one entry per reported thing,200+ // event id or blob hash, with the report's type and words as the reason.201+ const seen = new Set<string>();202+ const out: { id: string; reason: string }[] = [];203+ for (const r of relay.sql.exec<{ target_event: string; type: string; content: string }>(`SELECT target_event, type, content FROM reports WHERE status='open' AND target_event<>'' ORDER BY at DESC LIMIT 500`)) {204+ if (seen.has(r.target_event)) continue;205+ seen.add(r.target_event);206+ out.push({ id: r.target_event, reason: [r.type, r.content.slice(0, 200)].filter(Boolean).join(": ") });207+ }208+ return reply({ result: out });209+ }198210 case "listreports": {199211 const status = str(0) || "open";200212 return reply({ result: relay.sql.exec(`SELECT * FROM reports WHERE status=? ORDER BY at DESC LIMIT 200`, status).toArray() });
M src/roles.ts +1 -1