Skip to content

Commit 2adc270

Browse files
committed
[antispam] experimenting (WIP)
1 parent 1b06e7e commit 2adc270

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

.github/workflows/scripts/antispam.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ async function when_suspicious({ github, context, failed_checks }){
2121

2222
const reasons = failed_checks.map(check => `- ${check.reason}`).join("\n");
2323
const commentBody = `This issue/PR has been automatically flagged as [suspicious] as it might not meet contribution requirements.
24-
Please read our contribution guide before submitting.
25-
26-
Reason(s):
24+
Please read our contribution guide before submitting.
25+
26+
Reason(s):
2727
28-
${reasons}
28+
${reasons}
2929
`;
3030

31-
console.log(">>> DEBUG", commentBody);
31+
console.log(">>> DEBUG:\n", commentBody);
3232

3333
// await github.rest.issues.createComment({
3434
// owner,
@@ -66,7 +66,6 @@ module.exports = async ({ github, context, core }) => {
6666

6767
const { data: user } = await github.rest.users.getByUsername({ username: author });
6868

69-
7069
const was_author_account_recently_created = (() => {
7170

7271
const time_point = (() => {
@@ -81,7 +80,7 @@ module.exports = async ({ github, context, core }) => {
8180
create_at: create_at
8281
});
8382

84-
return create_at >= time_point;
83+
return create_at <= time_point;
8584
})();
8685

8786
const is_author_only_contribution_on_GH = (async () => {
@@ -98,14 +97,16 @@ module.exports = async ({ github, context, core }) => {
9897
return events.length === 0;
9998
})();
10099

100+
console.log(">>> context.payload:", context.payload)
101+
101102
const checks = [
102-
new Check(() => was_author_account_recently_created, "Account is less than an hour old"),
103-
new Check(() => is_author_only_contribution_on_GH, "First contribution to any GitHub project"),
103+
new Check(() => was_author_account_recently_created(), "Account is less than an hour old"),
104+
new Check(() => is_author_only_contribution_on_GH(), "First contribution to any GitHub project"),
104105
new Check(() => user.followers === 0 && user.following === 0, "Author has no relationships"),
105106
new Check(() => user.public_repos === 0 && user.public_gists === 0, "Author has no public reop/gist"),
106107
];
107108

108-
const failed_checks = checks.filter(check => ! check.evaluate());
109+
const failed_checks = checks.filter(check => check.evaluate());
109110

110111
const threshold = 0;
111112
console.log(">>> failed_checks amount: ", failed_checks.length, "vs. threshold: ", threshold)

0 commit comments

Comments
 (0)