···1414 (postCheck) => postCheck.label,
1515 );
16161717- // Destructure Post object
1818- const { did, time, atURI, text, cid } = post[0];
1919-2017 // iterate through the labels
2118 labels.forEach((label) => {
2219 const checkPost = POST_CHECKS.find(
···2421 );
25222623 if (checkPost?.ignoredDIDs) {
2727- if (checkPost.ignoredDIDs.includes(did)) {
2828- return logger.info(`Whitelisted DID: ${did}`);
2424+ if (checkPost?.ignoredDIDs.includes(post[0].did)) {
2525+ logger.info(`Whitelisted DID: ${post[0].did}`);
2626+ return;
2927 }
3030- } else {
3131- if (checkPost!.check.test(text)) {
3232- if (checkPost?.whitelist) {
3333- if (checkPost?.whitelist.test(text)) {
3434- logger.info(`Whitelisted phrase found"`);
3535- return;
3636- }
3737- } else {
3838- logger.info(`${checkPost!.label} in post at ${atURI}`);
2828+ }
2929+3030+ if (checkPost!.check.test(post[0].text)) {
3131+ // Check if post is whitelisted
3232+ if (checkPost?.whitelist) {
3333+ if (checkPost?.whitelist.test(post[0].text)) {
3434+ logger.info(`Whitelisted phrase found"`);
3535+ return;
3636+ }
3737+ }
39384040- if (checkPost!.reportOnly === true) {
4141- logger.info(`Report only: ${did}`);
4242- createAccountReport(
4343- did,
4444- `${time}: ${checkPost?.comment} at ${atURI} with text "${text}"`,
4545- );
4646- return;
4747- } else {
4848- logger.info(`Labeling post: ${atURI}`);
3939+ if (checkPost!.toLabel === true) {
4040+ logger.info(`Labeling post: ${post[0].atURI} for ${checkPost!.label}`);
4141+ createPostLabel(
4242+ post[0].atURI,
4343+ post[0].cid,
4444+ `${checkPost!.label}`,
4545+ `${post[0].time}: ${checkPost!.comment} at ${post[0].atURI} with text "${post[0].text}"`,
4646+ );
4747+ }
49485050- createPostLabel(
5151- post[0].atURI,
5252- post[0].cid,
5353- `${checkPost!.label}`,
5454- `${post[0].time}: ${checkPost!.comment} at ${post[0].atURI} with text "${post[0].text}"`,
5555- );
4949+ if (checkPost!.reportAcct === true) {
5050+ logger.info(`${checkPost!.label} in post at ${post[0].atURI}`);
5151+ logger.info(`Report only: ${post[0].did}`);
5252+ createAccountReport(
5353+ post[0].did,
5454+ `${post[0].time}: ${checkPost?.comment} at ${post[0].atURI} with text "${post[0].text}"`,
5555+ );
5656+ }
56575757- if (checkPost!.commentOnly === true) {
5858- logger.info(`Comment only: ${post[0].did}`);
5959- createAccountComment(
6060- post[0].did,
6161- `${post[0].time}: ${checkPost?.comment} at ${post[0].atURI} with text "${post[0].text}"`,
6262- );
6363- return;
6464- } else if (checkPost?.label === "fundraising-link" || checkPost?.label === "twitter-x") {
6565- return; // skip fundraising links—hardcoded because of the insane volume by spammers.
6666- } else if (checkPost!.commentOnly === false) {
6767- logger.info(
6868- `Creating report for post ${post[0].atURI} on ${post[0].did}`,
6969- );
7070- createAccountReport(
7171- post[0].did,
7272- ` ${post[0].time}: ${checkPost!.comment} at ${post[0].atURI} with text "${post[0].text}"`,
7373- );
7474- }
7575- }
7676- }
5858+ if (checkPost!.commentAcct === true) {
5959+ logger.info(`Comment on account: ${post[0].did}`);
6060+ createAccountComment(
6161+ post[0].did,
6262+ `${post[0].time}: ${checkPost?.comment} at ${post[0].atURI} with text "${post[0].text}"`,
6363+ );
7764 }
7865 }
7966 });
+41-43
src/checkProfiles.ts
···55 createAccountReport,
66 createAccountLabel,
77 checkAccountLabels,
88+ createAccountComment,
89} from "./moderation.js";
910import { limit } from "./limits.js";
1011···1415 displayName: string,
1516 description: string,
1617) => {
1717- const ActLabelChk = await limit(() => checkAccountLabels(did));
1818- // Get a list of labels
1918 const labels: string[] = Array.from(
2019 PROFILE_CHECKS,
2120 (profileCheck) => profileCheck.label,
···3029 // Check if DID is whitelisted
3130 if (checkProfiles?.ignoredDIDs) {
3231 if (checkProfiles.ignoredDIDs.includes(did)) {
3333- return logger.info(`Whitelisted DID: ${did}`);
3232+ logger.info(`Whitelisted DID: ${did}`);
3333+ return;
3434 }
3535 }
36363737 if (description) {
3838 if (checkProfiles?.description === true) {
3939 if (checkProfiles!.check.test(description)) {
4040+ // Check if description is whitelisted
4041 if (checkProfiles!.whitelist) {
4142 if (checkProfiles!.whitelist.test(description)) {
4243 logger.info(`Whitelisted phrase found.`);
4344 return;
4445 }
4545- } else {
4646- logger.info(`${checkProfiles!.label} in description for ${did}`);
4646+ }
4747+4848+ if (checkProfiles!.toLabel === true) {
4949+ logger.info(`Creating label for ${did}`);
5050+ createAccountLabel(
5151+ did,
5252+ `${checkProfiles!.label}`,
5353+ `${time}: ${checkProfiles!.comment} - ${displayName} - ${description}`,
5454+ );
4755 }
48564949- if (checkProfiles!.reportOnly === true) {
5757+ if (checkProfiles!.reportAcct === true) {
5058 createAccountReport(
5159 did,
5260 `${time}: ${checkProfiles!.comment} - ${displayName} - ${description}`,
5361 );
5454- return;
5555- } else {
5656- if (ActLabelChk) {
5757- if (ActLabelChk.includes(checkProfiles!.label)) {
5858- logger.info(
5959- `Label ${checkProfiles!.label} already exists for ${did}`,
6060- );
6161- return;
6262- }
6363- } else {
6464- createAccountLabel(
6565- did,
6666- `${checkProfiles!.label}`,
6767- `${time}: ${checkProfiles!.comment} - ${displayName} - ${description}`,
6868- );
6969- }
6262+ }
6363+6464+ if (checkProfiles!.commentAcct === true) {
6565+ logger.info(`Commenting on account for ${did}`);
6666+ createAccountComment(
6767+ did,
6868+ `${time}: ${checkProfiles!.comment} - ${displayName} - ${description}`,
6969+ );
7070 }
7171 }
7272 }
···8080 displayName: string,
8181 description: string,
8282) => {
8383- const ActLabelChk = await limit(() => checkAccountLabels(did));
8483 // Get a list of labels
8584 const labels: string[] = Array.from(
8685 PROFILE_CHECKS,
···9695 // Check if DID is whitelisted
9796 if (checkProfiles?.ignoredDIDs) {
9897 if (checkProfiles.ignoredDIDs.includes(did)) {
9999- return logger.info(`Whitelisted DID: ${did}`);
9898+ logger.info(`Whitelisted DID: ${did}`);
9999+ return;
100100 }
101101 }
102102103103 if (displayName) {
104104 if (checkProfiles?.displayName === true) {
105105 if (checkProfiles!.check.test(displayName)) {
106106+ // Check if displayName is whitelisted
106107 if (checkProfiles!.whitelist) {
107108 if (checkProfiles!.whitelist.test(displayName)) {
108109 logger.info(`Whitelisted phrase found.`);
109110 return;
110111 }
111111- } else {
112112- logger.info(`${checkProfiles!.label} in displayName for ${did}`);
112112+ }
113113+114114+ if (checkProfiles!.toLabel === true) {
115115+ createAccountLabel(
116116+ did,
117117+ `${checkProfiles!.label}`,
118118+ `${time}: ${checkProfiles!.comment} - ${displayName} - ${description}`,
119119+ );
113120 }
114121115115- if (checkProfiles!.reportOnly === true) {
122122+ if (checkProfiles!.reportAcct === true) {
116123 createAccountReport(
117124 did,
118125 `${time}: ${checkProfiles!.comment} - ${displayName} - ${description}`,
119126 );
120120- return;
121121- } else {
122122- if (ActLabelChk) {
123123- if (ActLabelChk.includes(checkProfiles!.label)) {
124124- logger.info(
125125- `Label ${checkProfiles!.label} already exists for ${did}`,
126126- );
127127- return;
128128- }
129129- } else {
130130- createAccountLabel(
131131- did,
132132- `${checkProfiles!.label}`,
133133- `${time}: ${checkProfiles!.comment} - ${displayName} - ${description}`,
134134- );
135135- }
127127+ }
128128+129129+ if (checkProfiles!.commentAcct === true) {
130130+ createAccountComment(
131131+ did,
132132+ `${time}: ${checkProfiles!.comment} - ${displayName} - ${description}`,
133133+ );
136134 }
137135 }
138136 }
+69-2
src/checkStarterPack.ts
···11-import { PROFILE_CHECKS } from "./constants.js";
11+import { PROFILE_CHECKS, STARTERPACK_CHECKS } from "./constants.js";
22import logger from "./logger.js";
33-import { createAccountLabel } from "./moderation.js";
33+import {
44+ createAccountLabel,
55+ createAccountReport,
66+ createPostLabel,
77+} from "./moderation.js";
4859export const checkStarterPack = async (
610 did: string,
···4044 }
4145 });
4246};
4747+4848+export const checkNewStarterPack = async (
4949+ did: string,
5050+ time: number,
5151+ atURI: string,
5252+ cid: string,
5353+ packName: string | undefined,
5454+ description: string | undefined,
5555+) => {
5656+ const labels: string[] = Array.from(
5757+ STARTERPACK_CHECKS,
5858+ (SPCheck) => SPCheck.label,
5959+ );
6060+6161+ labels.forEach((label) => {
6262+ const checkList = PROFILE_CHECKS.find((SPCheck) => SPCheck.label === label);
6363+6464+ if (checkList?.knownVectors?.includes(did)) {
6565+ createPostLabel(
6666+ atURI,
6767+ cid,
6868+ `${checkList!.label}`,
6969+ `${time}: Starter pack created by known vector for ${checkList!.label} at: ${atURI}"`,
7070+ );
7171+ createAccountReport(
7272+ did,
7373+ `${time}: Starter pack created by known vector for ${checkList!.label} at: ${atURI}"`,
7474+ );
7575+ }
7676+7777+ if (description) {
7878+ if (checkList!.check.test(description)) {
7979+ logger.info(`Labeling post: ${atURI}`);
8080+ createPostLabel(
8181+ atURI,
8282+ cid,
8383+ `${checkList!.label}`,
8484+ `${time}: ${checkList!.comment} at ${atURI} with text "${description}"`,
8585+ );
8686+ createAccountReport(
8787+ did,
8888+ `${time}: ${checkList!.comment} at ${atURI} with text "${description}"`,
8989+ );
9090+ }
9191+ }
9292+9393+ if (packName) {
9494+ if (checkList!.check.test(packName)) {
9595+ logger.info(`Labeling post: ${atURI}`);
9696+ createPostLabel(
9797+ atURI,
9898+ cid,
9999+ `${checkList!.label}`,
100100+ `${time}: ${checkList!.comment} at ${atURI} with pack name "${packName}"`,
101101+ );
102102+ createAccountReport(
103103+ did,
104104+ `${time}: ${checkList!.comment} at ${atURI} with pack name "${packName}"`,
105105+ );
106106+ }
107107+ }
108108+ });
109109+};
+12-8
src/constants.ts.example
···88 comment: "Pro-skub language found in profile",
99 description: true,
1010 displayName: true,
1111- reportOnly: false,
1212- commentOnly: false,
1111+ reportAcct: false,
1212+ commentAcct: false,
1313+ toLabel: true,
1314 check: new RegExp(
1415 "(only|pro)[ -]skub|we love skub|skub is (good|god|king)|\\bskub\\b",
1516 "i",
···2425 comment: "skub-adjacent language found in profile",
2526 description: true,
2627 displayName: true,
2727- reportOnly: true,
2828- commentOnly: false,
2828+ reportAcct: false,
2929+ commentAcct: false,
3030+ toLabel: true,
2931 check: new RegExp(
3032 "skubbe",
3133 "i",
···3739 {
3840 label: "skub",
3941 comment: "Pro-skub language found in handle",
4040- reportOnly: false,
4141- commentOnly: false,
4242+ reportAcct: false,
4343+ commentAcct: false,
4444+ toLabel: true,
4245 check: new RegExp(
4346 "(only|pro)[-]skub|we love skub|skub[-]?is[-]?(good|god|king)|skub\\.(pro|com|org)",
4447 "i",
···5053 {
5154 label: "pro-skub-link",
5255 comment: "Pro Skub link found in post",
5353- reportOnly: true,
5454- commentOnly: false,
5656+ reportAcct: false,
5757+ commentAcct: true,
5858+ toLabel: true,
5559 check: new RegExp(
5660 "skubbe\\.com|skub\\.(me|pro|tech)",
5761 "i",
+4-3
src/developing_checks.md
···1212 comment: "Example found in handle",
1313 description: true, // Optional, only used in handle checks
1414 displayName: true, // Optional, only used in handle checks
1515- reportOnly: false, // it true, the check will only report the content against the account, not label.
1616- commentOnly: false, // Poorly named, if true, will generate an account level comment from flagged posts, rather than a report. Intended for use when reportOnly is false, and on posts only where the flag may generate a high volume of reports..
1515+ reportAcct: false, // it true, the check will only report the content against the account, not label.
1616+ commentOnly: false, // if true, will generate an account level comment from flagged posts, rather than a report. Intended for use when reportAcct is false, and on posts only where the flag may generate a high volume of reports.
1717+ toLabel: true, // Should the handle in question be labeled if check evaluates to true.
1718 check: new RegExp("example", "i"), // Regular expression to match against the content
1819 whitelist: new RegExp("example.com", "i"), // Optional, regular expression to whitelist content
1919- ignoredDIDs: ["did:plc:example"] // Optional, array of DIDs to ignore if they match the check. Useful for folks who reclaim words.
2020+ ignoredDIDs: ["did:plc:example"] // Optional, array of DIDs to ignore if they match the check. Useful for folks who reclaim words or accounts which may be false positives.
2021 }
2122];
2223```