11// Git + Facebook Webhook API
22// Created by: Chaelgutierrez, Mharchicano
33
4- " use strict" ;
4+ ' use strict' ;
55
6- require ( " dotenv" ) . config ( ) ;
7- const login = require ( " facebook-chat-api" ) ;
8- const shell = require ( " shelljs" ) ;
9- const ip = require ( "ip" ) ;
10- const fastify = require ( " fastify" ) ( {
11- logger : true
6+ require ( ' dotenv' ) . config ( ) ;
7+ const login = require ( ' facebook-chat-api' ) ;
8+ const shell = require ( ' shelljs' ) ;
9+ const ip = require ( 'ip' ) ;
10+ const fastify = require ( ' fastify' ) ( {
11+ logger : true ,
1212} ) ;
1313
1414let host = ip . address ( ) ;
15- let port = process . env . WEBHOOK_PORT ? process . env . WEBHOOK_PORT : " 8080" ;
15+ let port = process . env . WEBHOOK_PORT ? process . env . WEBHOOK_PORT : ' 8080' ;
1616let AUTHOR = null ;
1717let DATE = null ;
1818let HASH = null ;
@@ -22,32 +22,32 @@ let THREAD = null;
2222let POST_DATA = null ;
2323let HEADER = process . env . TITLE ;
2424
25- fastify . post ( " /integrate/webhook/:tid" , function ( request , reply ) {
25+ fastify . post ( ' /integrate/webhook/:tid' , function ( request , reply ) {
2626 let body = request . body ;
2727
2828 THREAD = request . params . tid ;
29- AUTHOR = " Author: " + body . commits [ 0 ] . author . name . trim ( ) ;
30- BRANCH = " Branch: " + body . ref . replace ( " refs/heads/" , "" ) . trim ( ) ;
31- DATE = " Date: " + body . commits [ 0 ] . timestamp . trim ( ) ;
32- HASH = " Hash: " + body . commits [ 0 ] . id . trim ( ) ;
33- COMMIT = " Commit: " + body . commits [ 0 ] . message . trim ( ) ;
29+ AUTHOR = ' Author: ' + body . commits [ 0 ] . author . name . trim ( ) ;
30+ BRANCH = ' Branch: ' + body . ref . replace ( ' refs/heads/' , '' ) . trim ( ) ;
31+ DATE = ' Date: ' + body . commits [ 0 ] . timestamp . trim ( ) ;
32+ HASH = ' Hash: ' + body . commits [ 0 ] . id . trim ( ) ;
33+ COMMIT = ' Commit: ' + body . commits [ 0 ] . message . trim ( ) ;
3434 POST_DATA = `\n${ HEADER } \n\n${ BRANCH } \n${ COMMIT } \n${ AUTHOR } \n${ DATE } \n${ HASH } \n` ;
3535
3636 if ( process . env . TITLE && process . env . EMAIL && process . env . PASSWORD ) {
3737 login (
3838 {
3939 email : process . env . EMAIL ,
40- password : process . env . PASSWORD
40+ password : process . env . PASSWORD ,
4141 } ,
4242 ( err , api ) => {
4343 if ( err ) {
4444 return console . error ( err ) ;
4545 } else {
4646 let yourID = THREAD ;
47- reply . send ( { success : true } ) ;
47+ reply . send ( { success : true } ) ;
4848 api . sendMessage ( POST_DATA , yourID ) ;
4949 }
50- }
50+ } ,
5151 ) ;
5252 } else {
5353 console . log ( "Oops!, there is something wrong with your '.env' file . . ." ) ;
0 commit comments