flotilla/src/app/actionItems.ts

24 lines
860 B
TypeScript
Raw Normal View History

2026-07-28 16:16:26 +00:00
import {derived} from "svelte/store"
2026-08-17 16:21:30 +00:00
import {REPORT, sortEventsDesc} from "@welshman/util"
import {rooms} from "@app/core"
import {deriveSpaceSupportedMethods} from "@app/management"
import {deriveEventsForUrl} from "@app/repository"
2026-07-28 16:16:26 +00:00
// Action items (admin review queue)
// A report is resolved by banning the event it names, a join request by allowing the pubkey, so
// the queue holds whichever of the two the user can actually act on.
export const deriveSpaceActionItems = (url: string) =>
derived(
[
deriveEventsForUrl(url, [{kinds: [REPORT]}]),
rooms.get().pendingJoins(url).$,
deriveSpaceSupportedMethods(url),
],
([$reports, $pendingJoins, $methods]) =>
sortEventsDesc([
...($methods.includes("banevent") ? $reports : []),
...($methods.includes("allowpubkey") ? $pendingJoins : []),
]),
)