A work-in-progress, horribly overpowered CLI for Ozone
1import { loginToService } from "./login.ts";
2import "@std/dotenv/load";
3import { parseArgs } from "@std/cli";
4import { getAllAppeals } from "./appeals.ts";
5
6if (import.meta.main) {
7 const {
8 _: [command],
9 } = parseArgs(Deno.args);
10 switch (command) {
11 case "autoappeal": {
12 const agent = await loginToService();
13 const appeals = await getAllAppeals(agent);
14 const {
15 data: { records },
16 } = await agent.tools.ozone.moderation.getRecords({
17 uris: appeals.map((d) => d.subject.uri),
18 });
19
20 for (const record of records) {
21 try {
22 const evt = {
23 subject: {
24 $type: "com.atproto.repo.strongRef",
25 uri: record.uri,
26 cid: record.cid,
27 },
28 createdBy: agent.did!,
29 subjectBlobCids: record.blobCids,
30 modTool: { name: "ozone-cli/autoappeal" },
31 };
32
33 // Remove ALL labels from each post
34 // @TODO add some sort of NLP to determine what action to take (i.e., replace label X with label Y)
35 await agent.tools.ozone.moderation.emitEvent({
36 ...evt,
37 event: {
38 $type: "tools.ozone.moderation.defs#modEventLabel",
39 createLabelVals: [],
40 negateLabelVals: record.labels,
41 comment: `Labels removed by ozone-cli at ${new Date().toISOString()}`,
42 },
43 });
44
45 // Acknowledge appeal
46 await agent.tools.ozone.moderation.emitEvent({
47 ...evt,
48 event: {
49 $type: "tools.ozone.moderation.defs#modEventAcknowledge",
50 comment: "ACK appeal",
51 acknowledgeAccountSubjects: false,
52 },
53 });
54
55 // Resolve appeal
56 await agent.tools.ozone.moderation.emitEvent({
57 ...evt,
58 event: {
59 $type: "tools.ozone.moderation.defs#modEventResolveAppeal",
60 comment: "Resolving appeal",
61 },
62 });
63 } catch (e) {
64 console.error(e);
65 console.error(record);
66 }
67 }
68 }
69 }
70}