File tree Expand file tree Collapse file tree 2 files changed +42
-18
lines changed Expand file tree Collapse file tree 2 files changed +42
-18
lines changed Original file line number Diff line number Diff line change
1
+ const db = require ( '../../db' ) ;
2
+
3
+ const attemptAutoApproval = async ( action ) => {
4
+ try {
5
+ const attestation = {
6
+ timestamp : new Date ( ) ,
7
+ autoApproved : true ,
8
+ } ;
9
+ await db . authorise ( action . id , attestation ) ;
10
+ console . log ( 'Push automatically approved by system.' ) ;
11
+
12
+ return true ;
13
+ } catch ( error ) {
14
+ console . error ( 'Error during auto-approval:' , error . message ) ;
15
+ return false ;
16
+ }
17
+ } ;
18
+
19
+ const attemptAutoRejection = async ( action ) => {
20
+ try {
21
+ const attestation = {
22
+ timestamp : new Date ( ) ,
23
+ autoApproved : true ,
24
+ } ;
25
+ await db . reject ( action . id , attestation ) ;
26
+ console . log ( 'Push automatically rejected by system.' ) ;
27
+
28
+ return true ;
29
+ } catch ( error ) {
30
+ console . error ( 'Error during auto-rejection:' , error . message ) ;
31
+ return false ;
32
+ }
33
+ } ;
34
+
35
+ module . exports = {
36
+ attemptAutoApproval,
37
+ attemptAutoRejection,
38
+ } ;
Original file line number Diff line number Diff line change 1
1
const proc = require ( './processors' ) ;
2
- const db = require ( '../db ' ) ;
2
+ const { attemptAutoApproval , attemptAutoRejection } = require ( './actions/autoActions ' ) ;
3
3
4
4
const pushActionChain = [
5
5
proc . push . parsePush ,
@@ -21,22 +21,6 @@ const pullActionChain = [proc.push.checkRepoInAuthorisedList];
21
21
22
22
let pluginsInserted = false ;
23
23
24
- const attemptAutoApproval = async ( req , action ) => {
25
- try {
26
- const attestation = {
27
- timestamp : new Date ( ) ,
28
- autoApproved : true ,
29
- } ;
30
- await db . authorise ( action . id , attestation ) ;
31
- console . log ( 'Push automatically approved by system.' ) ;
32
-
33
- return true ;
34
- } catch ( error ) {
35
- console . error ( 'Error during auto-approval:' , error . message ) ;
36
- return false ;
37
- }
38
- } ;
39
-
40
24
const executeChain = async ( req ) => {
41
25
let action ;
42
26
try {
@@ -58,7 +42,9 @@ const executeChain = async (req) => {
58
42
} finally {
59
43
await proc . push . audit ( req , action ) ;
60
44
if ( action . autoApproved ) {
61
- attemptAutoApproval ( req , action ) ;
45
+ attemptAutoApproval ( action ) ;
46
+ } else if ( action . autoRejected ) {
47
+ attemptAutoRejection ( action ) ;
62
48
}
63
49
}
64
50
You can’t perform that action at this time.
0 commit comments