Add GitHub signup oracle #41

Merged
bumi merged 13 commits from feature/github-signup into master 2019-08-28 13:56:54 +00:00
Showing only changes of commit 342a5cd829 - Show all commits

View File

@@ -24,9 +24,10 @@ module.exports = async function(robot, kredits) {
robot.logger.debug('[hubot-kredits] Ignoring GitHub actions from ', util.inspect(repoBlackList));
}
const kreditsWebUrl = process.env.KREDITS_WEB_URL || 'https://kredits.kosmos.org';
const Contributor = kredits.Contributor;
const Contribution = kredits.Contribution;
const kreditsWebUrl = process.env.KREDITS_WEB_URL || 'https://kredits.kosmos.org';
function getContributorByGithubUser(username) {
return Contributor.all().then(contributors => {
@@ -240,7 +241,7 @@ module.exports = async function(robot, kredits) {
contributorAttr.github_username = user.login;
contributorAttr.github_uid = user.id;
kredits.Contributor.add(contributorAttr)
kredits.Contributor.add(contributorAttr, { gasLimit: 350000 })
.then(transaction => {
robot.logger.info('[hubot-kredits] Contributor added from GitHub signup', transaction.hash);
res.status(201);
@@ -248,6 +249,9 @@ module.exports = async function(robot, kredits) {
transactionHash: transaction.hash,
raucao commented 2019-07-26 10:30:08 +00:00 (Migrated from github.com)
Review

Would be useful to know from where and how the contributor was added exactly. We use the [hubot-kredits] prefix in the other files. And could add something like "Contributor added from GitHub signup".

However, creating the contributor needs to be separated from the GitHub hook, because in order to create a more complete profile, we should be able to add more accounts before creating the contributor on chain. This is important, because the bot shouldn't have permission to update hashes afterwards, only to create new contributor records.

Splitting that out can be done in a future PR, of course, but maybe it makes sense to at least split out the functionality from the route already.

Would be useful to know from where and how the contributor was added exactly. We use the `[hubot-kredits]` prefix in the other files. And could add something like "Contributor added from GitHub signup". However, creating the contributor needs to be separated from the GitHub hook, because in order to create a more complete profile, we should be able to add more accounts *before* creating the contributor on chain. This is important, because the bot shouldn't have permission to update hashes afterwards, only to create new contributor records. Splitting that out can be done in a future PR, of course, but maybe it makes sense to at least split out the functionality from the route already.
galfert commented 2019-07-26 19:03:22 +00:00 (Migrated from github.com)
Review

I changed the log message. But apart from adding the CORS headers I didn't work on the signup route itself. So I don't know exactly how or what to split out. Maybe @bumi can jump in here?

I changed the log message. But apart from adding the CORS headers I didn't work on the signup route itself. So I don't know exactly how or what to split out. Maybe @bumi can jump in here?
github_username: user.login
});
}).catch((error) => {
robot.logger.error(`[hubot-kredits] Error adding contributor:`, error);
res.sendStatus(500);
});
} else {
res.json({