forked from G-Research/git-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoActions.js
38 lines (33 loc) · 861 Bytes
/
autoActions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const db = require('../../db');
const attemptAutoApproval = async (action) => {
try {
const attestation = {
timestamp: new Date(),
autoApproved: true,
};
await db.authorise(action.id, attestation);
console.log('Push automatically approved by system.');
return true;
} catch (error) {
console.error('Error during auto-approval:', error.message);
return false;
}
};
const attemptAutoRejection = async (action) => {
try {
const attestation = {
timestamp: new Date(),
autoApproved: true,
};
await db.reject(action.id, attestation);
console.log('Push automatically rejected by system.');
return true;
} catch (error) {
console.error('Error during auto-rejection:', error.message);
return false;
}
};
module.exports = {
attemptAutoApproval,
attemptAutoRejection,
};