···
1
-
import { AppBskyActorDefs, Agent } from "@atproto/api";
2
-
import { DID, PRONOUNS, URIs } from "./constants.js";
1
+
import { AppBskyActorDefs } from "@atproto/api";
2
+
import { DID, PRONOUNS, SIGNING_KEY, URIs } from "./constants.js";
3
+
import { LabelerServer } from "@skyware/labeler";
4
+
import { getAgent } from "./agent.js";
6
+
const server = new LabelerServer({ did: DID, signingKey: SIGNING_KEY });
7
+
const agent = await getAgent();
9
+
server.start(4001, (error, address) => {
11
+
console.error(error);
13
+
console.log(`Labeler server listening on ${address}`);
export const label = async (
subject: string | AppBskyActorDefs.ProfileView,
const did = AppBskyActorDefs.isProfileView(subject) ? subject.did : subject;
const labels = await agent.com.atproto.label
11
-
.queryLabels({ sources: [DID], uriPatterns: [did] })
23
+
.queryLabels({ sources: [server.did], uriPatterns: [did] })
···
if (post?.includes("Like this post to delete")) {
21
-
.withProxy("atproto_labeler", DID)
22
-
.tools.ozone.moderation.emitEvent({
24
-
$type: "tools.ozone.moderation.defs#modEventLabel",
25
-
createLabelVals: [],
26
-
negateLabelVals: labels.data.labels.map((label) => label.val),
29
-
$type: "com.atproto.admin.defs#repoRef",
32
-
createdBy: agent.did!,
33
-
createdAt: new Date().toISOString(),
34
-
subjectBlobCids: [],
35
+
{ negate: labels.data.labels.map((label) => label.val) },
.then(() => console.log(`Deleted labels for ${did}`));
} else if (labels.data.labels.length < 4 && PRONOUNS[post]) {
42
-
.withProxy("atproto_labeler", DID)
43
-
.tools.ozone.moderation.emitEvent({
45
-
$type: "tools.ozone.moderation.defs#modEventLabel",
46
-
createLabelVals: [PRONOUNS[post]],
47
-
negateLabelVals: [],
50
-
$type: "com.atproto.admin.defs#repoRef",
53
-
createdBy: agent.did!,
54
-
createdAt: new Date().toISOString(),
55
-
subjectBlobCids: [],
46
+
val: PRONOUNS[post],
47
+
cts: new Date().toISOString(),