10 Commits

Author SHA1 Message Date
9f078a0d84 1.5.0 2017-05-13 17:05:23 +02:00
b1ea520fdf Improve wording, add URLs 2017-05-13 17:05:08 +02:00
6d98c2cf19 1.4.6 2017-05-13 16:37:05 +02:00
7d8c6032c9 Fix payload parsing 2017-05-13 16:36:48 +02:00
8596483721 1.4.5 2017-05-13 15:49:38 +02:00
f54e124dba Fix diverging webhook object structure
No idea why, but on the server, all data is contained within a single
'payload' property, while I've never seen any such property on my
machine. Could be different node or express versions, but in any case,
this should fix it so that it just works no matter what.
2017-05-13 15:47:35 +02:00
fb8fc88101 1.4.4 2017-05-13 15:15:30 +02:00
6ca1254c9a Fix GitHub POST handler
1. robot.logger.debug didn't show any output
2. Send response for all requests
2017-05-13 15:14:22 +02:00
38483cbbeb 1.4.3 2017-05-12 14:02:54 +02:00
0203cb1a62 Fix typo 2017-05-12 14:02:46 +02:00
2 changed files with 11 additions and 5 deletions

View File

@@ -49,7 +49,7 @@ const Web3 = require('web3');
getBalance().then(balance => {
if (balance <= 0) {
messageRoom(`Yo gang, I\m broke! Please drop me some ETH to ${hubotWalletAddress}. kthxbai.`);
messageRoom(`Yo gang, I\'m broke! Please drop me some ETH to ${hubotWalletAddress}. kthxbai.`);
}
});
@@ -158,10 +158,10 @@ const Web3 = require('web3');
getContributorByGithubUser(recipient).then(c => {
kredits.addProposal(c.address, amount, url, '', (e/* , d */) => {
if (e) { reject(); return; }
messageRoom(`New proposal created: ${amount} for ${recipient}`);
messageRoom(`Let's give ${recipient} some kredits for ${url}! We just need two votes: https://kredits.kosmos.org`);
});
}, () => {
messageRoom(`Couldn\'t find contributor data for ${recipient}. Please add them first!`);
messageRoom(`I wanted to propose giving kredits to ${recipient} for ${url}, but I can't find their contact data. Please add them as a contributor: https://kredits.kosmos.org`);
});
resolve();
@@ -246,13 +246,19 @@ const Web3 = require('web3');
robot.router.post('/incoming/kredits/github/'+process.env.KREDITS_WEBHOOK_TOKEN, (req, res) => {
let evt = req.header('X-GitHub-Event');
let data = req.body;
robot.logger.debug(`Received GitHub hook. Event: ${evt}, action: ${data.action}`);
// For some reason data is contained in a payload property on one
// machine, but directly in the root of the object on others
if (data.payload) { data = JSON.parse(data.payload); }
robot.logger.info(`Received GitHub hook. Event: ${evt}, action: ${data.action}`);
if (evt === 'pull_request' && data.action === 'closed') {
handleGitHubPullRequestClosed(data).then(() => res.send(200));
}
else if (evt === 'issues' && data.action === 'closed') {
handleGitHubIssueClosed(data).then(() => res.send(200));
} else {
res.send(200);
}
});

View File

@@ -1,6 +1,6 @@
{
"name": "hubot-kredits",
"version": "1.4.2",
"version": "1.5.0",
"description": "Kosmos Kredits functionality for chat bots",
"main": "index.js",
"scripts": {