mirror of
https://github.com/status-im/autobounty.git
synced 2025-02-28 04:50:41 +00:00
Alpha test: secret webhook
This commit is contained in:
parent
83f4c808be
commit
9e7b06b523
@ -5,3 +5,6 @@ EXPOSE 8080
|
||||
|
||||
# Set this variable to the name of your production config file (without the extension)
|
||||
ENV NODE_ENV development
|
||||
|
||||
# Set this variable to the value of the secret field of the Github webhook
|
||||
ENV WEBHOOK_SECRET ''
|
||||
|
@ -113,7 +113,7 @@ const logTransaction = function (txId, from, to, amount, gasPrice) {
|
||||
logger.info("====================================================");
|
||||
}
|
||||
|
||||
const log = function (msg) {
|
||||
const info = function (msg) {
|
||||
logger.info(msg);
|
||||
}
|
||||
|
||||
|
13
index.js
13
index.js
@ -43,17 +43,17 @@ app.post(`${config.urlEndpoint}`, jsonParser, function (req, res, next) {
|
||||
setTimeout(() => {
|
||||
processRequest(req)
|
||||
.then(() => {
|
||||
bot.info('issue well funded: ' + res.body.issue.url);
|
||||
bot.info('issue well funded: ' + req.body.issue.url);
|
||||
})
|
||||
.catch((err) => {
|
||||
bot.error('Error funding issue: ' + req.body.issue.url);
|
||||
bot.error('Error processing request: ' + req.body.issue.url);
|
||||
bot.error('error: ' + err);
|
||||
bot.error('dump: ' + req);
|
||||
bot.error('dump: ' + req.body);
|
||||
});
|
||||
}, config.delayInMiliSeconds);
|
||||
|
||||
} else {
|
||||
bot.error('Error funding issue: ' + req.body.issue.url);
|
||||
bot.error('Error validating issue: ' + req.body.issue.url);
|
||||
bot.error('error: ' + validation.error);
|
||||
}
|
||||
return res.sendStatus(200);
|
||||
@ -69,8 +69,7 @@ const validateRequest = function (req) {
|
||||
'Please set env variable WEBHOOK_SECRET to github\'s webhook secret value';
|
||||
} else {
|
||||
|
||||
|
||||
const blob = JSON.stringify(req.body);
|
||||
const blob = JSON.stringify(req.body);
|
||||
const hmac = crypto.createHmac('sha1', webhookSecret);
|
||||
const ourSignature = `sha1=${hmac.update(blob).digest('hex')}`;
|
||||
|
||||
@ -153,5 +152,5 @@ const sendTransaction = function (eth, from, to, amount, gasPrice) {
|
||||
|
||||
const port = process.env.PORT || 8181
|
||||
app.listen(port, function () {
|
||||
bot.log('Autobounty listening on port', port);
|
||||
bot.info('Autobounty listening on port', port);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user