Skip to content

Commit 1b06e7e

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

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

.github/workflows/scripts/antispam.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ async function when_suspicious({ github, context, failed_checks }){
33
// might wanna use a score of confidence (how suspicious it is), then react on that
44

55
const { owner, repo } = context.repo;
6-
const issueNumber = context.payload.issue.number;
6+
const issueNumber = context.payload.number; // either issue or PR
77

88
// await github.rest.issues.addLabels({
99
// owner,
@@ -68,17 +68,20 @@ module.exports = async ({ github, context, core }) => {
6868

6969

7070
const was_author_account_recently_created = (() => {
71-
const createdAt = new Date(user.created_at);
72-
const now = new Date();
73-
const accountAgeInMinutes = (now - createdAt) / (1000 * 60);
71+
72+
const time_point = (() => {
73+
let value = new Date();
74+
value.setHours(value.getHours() - 2);
75+
return value;
76+
});
77+
const create_at = new Date(user.created_at);
7478

7579
console.log(">>> was_author_account_recently_created: ", {
76-
now: now,
77-
createdAt: createdAt,
78-
accountAgeInMinutes: accountAgeInMinutes
80+
time_point: time_point,
81+
create_at: create_at
7982
});
8083

81-
return (accountAgeInMinutes < 60);
84+
return create_at >= time_point;
8285
})();
8386

8487
const is_author_only_contribution_on_GH = (async () => {
@@ -105,6 +108,7 @@ module.exports = async ({ github, context, core }) => {
105108
const failed_checks = checks.filter(check => ! check.evaluate());
106109

107110
const threshold = 0;
111+
console.log(">>> failed_checks amount: ", failed_checks.length, "vs. threshold: ", threshold)
108112
if (failed_checks.length <= threshold)
109113
return;
110114

0 commit comments

Comments
 (0)