Pronouns labels on Bluesky

replace DELETE constant with the rkey to the post

Changed files
+6 -7
src
+1 -2
src/constants.ts
···
export const SIGNING_KEY = process.env.SIGNING_KEY ?? "";
export const PORT = 4001;
export const LABEL_LIMIT = 4;
-
export const DELETE = "delete";
export const POSTS: Record<string, string> = {
-
"3kwsqucto3j2a": DELETE,
"3kwss4ldkwd2j": "they",
"3kwss4fmiow2n": "it",
"3kwss4bzqlw2k": "he",
···
export const SIGNING_KEY = process.env.SIGNING_KEY ?? "";
export const PORT = 4001;
export const LABEL_LIMIT = 4;
+
export const DELETE = "3kwsqucto3j2a";
export const POSTS: Record<string, string> = {
"3kwss4ldkwd2j": "they",
"3kwss4fmiow2n": "it",
"3kwss4bzqlw2k": "he",
+5 -5
src/label.ts
···
export const label = async (
subject: string | AppBskyActorDefs.ProfileView,
-
uri: string,
) => {
const did = AppBskyActorDefs.isProfileView(subject) ? subject.did : subject;
···
return set;
}, new Set<string>());
-
if (POSTS[uri]?.includes(DELETE)) {
await server
.createLabels({ uri: did }, { negate: [...labels] })
.catch((err) => {
console.log(err);
})
.then(() => console.log(`Deleted labels for ${did}`));
-
} else if (labels.size < LABEL_LIMIT && POSTS[uri]) {
await server
-
.createLabel({ uri: did, val: POSTS[uri] })
.catch((err) => {
console.log(err);
})
-
.then(() => console.log(`Labeled ${did} with ${POSTS[uri]}`));
}
};
···
export const label = async (
subject: string | AppBskyActorDefs.ProfileView,
+
rkey: string,
) => {
const did = AppBskyActorDefs.isProfileView(subject) ? subject.did : subject;
···
return set;
}, new Set<string>());
+
if (rkey.includes(DELETE)) {
await server
.createLabels({ uri: did }, { negate: [...labels] })
.catch((err) => {
console.log(err);
})
.then(() => console.log(`Deleted labels for ${did}`));
+
} else if (labels.size < LABEL_LIMIT && POSTS[rkey]) {
await server
+
.createLabel({ uri: did, val: POSTS[rkey] })
.catch((err) => {
console.log(err);
})
+
.then(() => console.log(`Labeled ${did} with ${POSTS[rkey]}`));
}
};