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 11const proc = require ( './processors' ) ;
2- const db = require ( '../db ' ) ;
2+ const { attemptAutoApproval , attemptAutoRejection } = require ( './actions/autoActions ' ) ;
33
44const pushActionChain = [
55 proc . push . parsePush ,
@@ -21,22 +21,6 @@ const pullActionChain = [proc.push.checkRepoInAuthorisedList];
2121
2222let pluginsInserted = false ;
2323
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-
4024const executeChain = async ( req ) => {
4125 let action ;
4226 try {
@@ -58,7 +42,9 @@ const executeChain = async (req) => {
5842 } finally {
5943 await proc . push . audit ( req , action ) ;
6044 if ( action . autoApproved ) {
61- attemptAutoApproval ( req , action ) ;
45+ attemptAutoApproval ( action ) ;
46+ } else if ( action . autoRejected ) {
47+ attemptAutoRejection ( action ) ;
6248 }
6349 }
6450
You can’t perform that action at this time.
0 commit comments