b3d90e1 · Redact ids outside the wall · 5 days ago
1
import type { Mapping } from "./mapping.ts";2
import type { ScopeGuard } from "./scope.ts";3
4
export function formatReport(opts: {5
mapping: Mapping;6
guard: ScopeGuard;7
broadcastId: string;8
replyCount: number;9
collectSeconds: number;10
}): string {11
opts.guard.require(opts.broadcastId, "report");12
const rooms = opts.mapping.channels.filter((c) => c.role === "room");13
const reports = opts.mapping.channels.filter((c) => c.role === "reports");14
return [15
`# report from ${opts.mapping.agent}`,16
`scope: ${opts.mapping.scope}`,17
`broadcast: ${opts.guard.redact(opts.broadcastId)}`,18
`rooms: ${rooms.length}`,19
`replies: ${opts.replyCount}`,20
`window: ${opts.collectSeconds}s`,21
`filed: ${reports.length} reports channel(s)`,22
"",23
].join("\n");24
}25