mirror of
https://github.com/status-im/autobounty.git
synced 2025-02-28 13:00:40 +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)
|
# Set this variable to the name of your production config file (without the extension)
|
||||||
ENV NODE_ENV development
|
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("====================================================");
|
logger.info("====================================================");
|
||||||
}
|
}
|
||||||
|
|
||||||
const log = function (msg) {
|
const info = function (msg) {
|
||||||
logger.info(msg);
|
logger.info(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
index.js
11
index.js
@ -43,17 +43,17 @@ app.post(`${config.urlEndpoint}`, jsonParser, function (req, res, next) {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
processRequest(req)
|
processRequest(req)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
bot.info('issue well funded: ' + res.body.issue.url);
|
bot.info('issue well funded: ' + req.body.issue.url);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.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('error: ' + err);
|
||||||
bot.error('dump: ' + req);
|
bot.error('dump: ' + req.body);
|
||||||
});
|
});
|
||||||
}, config.delayInMiliSeconds);
|
}, config.delayInMiliSeconds);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
bot.error('Error funding issue: ' + req.body.issue.url);
|
bot.error('Error validating issue: ' + req.body.issue.url);
|
||||||
bot.error('error: ' + validation.error);
|
bot.error('error: ' + validation.error);
|
||||||
}
|
}
|
||||||
return res.sendStatus(200);
|
return res.sendStatus(200);
|
||||||
@ -69,7 +69,6 @@ const validateRequest = function (req) {
|
|||||||
'Please set env variable WEBHOOK_SECRET to github\'s webhook secret value';
|
'Please set env variable WEBHOOK_SECRET to github\'s webhook secret value';
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
const blob = JSON.stringify(req.body);
|
const blob = JSON.stringify(req.body);
|
||||||
const hmac = crypto.createHmac('sha1', webhookSecret);
|
const hmac = crypto.createHmac('sha1', webhookSecret);
|
||||||
const ourSignature = `sha1=${hmac.update(blob).digest('hex')}`;
|
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
|
const port = process.env.PORT || 8181
|
||||||
app.listen(port, function () {
|
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