@@ -14,25 +14,17 @@ const fastify = require('fastify')({
1414const host = ip . address ( ) ;
1515const port = process . env . WEBHOOK_PORT ? process . env . WEBHOOK_PORT : '8080' ;
1616
17- let AUTHOR = null ;
18- let DATE = null ;
19- let HASH = null ;
20- let COMMIT = null ;
21- let BRANCH = null ;
22- let THREAD = null ;
23- let POST_DATA = null ;
24- let HEADER = process . env . TITLE ;
25-
2617fastify . post ( '/integrate/webhook/:tid' , function ( request , reply ) {
27- let body = request . body ;
18+ const body = request . body ;
2819
29- THREAD = request . params . tid ;
30- AUTHOR = 'Author: ' + body . commits [ 0 ] . author . name . trim ( ) ;
31- BRANCH = 'Branch: ' + body . ref . replace ( 'refs/heads/' , '' ) . trim ( ) ;
32- DATE = 'Date: ' + body . commits [ 0 ] . timestamp . trim ( ) ;
33- HASH = 'Hash: ' + body . commits [ 0 ] . id . trim ( ) ;
34- COMMIT = 'Commit: ' + body . commits [ 0 ] . message . trim ( ) ;
35- POST_DATA = `\n${ HEADER } \n\n${ BRANCH } \n${ COMMIT } \n${ AUTHOR } \n${ DATE } \n${ HASH } \n` ;
20+ const HEADER = process . env . TITLE ;
21+ const THREAD = request . params . tid ;
22+ const AUTHOR = 'Author: ' + body . commits [ 0 ] . author . name . trim ( ) ;
23+ const BRANCH = 'Branch: ' + body . ref . replace ( 'refs/heads/' , '' ) . trim ( ) ;
24+ const DATE = 'Date: ' + body . commits [ 0 ] . timestamp . trim ( ) ;
25+ const HASH = 'Hash: ' + body . commits [ 0 ] . id . trim ( ) ;
26+ const COMMIT = 'Commit: ' + body . commits [ 0 ] . message . trim ( ) ;
27+ const POST_DATA = `\n${ HEADER } \n\n${ BRANCH } \n${ COMMIT } \n${ AUTHOR } \n${ DATE } \n${ HASH } \n` ;
3628
3729 if ( process . env . TITLE && process . env . EMAIL && process . env . PASSWORD ) {
3830 login (
@@ -44,7 +36,7 @@ fastify.post('/integrate/webhook/:tid', function(request, reply) {
4436 if ( err ) {
4537 return console . error ( err ) ;
4638 } else {
47- let yourID = THREAD ;
39+ const yourID = THREAD ;
4840 reply . send ( { success : true } ) ;
4941 api . sendMessage ( POST_DATA , yourID ) ;
5042 }
0 commit comments