Add GitHub signup oracle #41
@@ -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,
|
||||
|
|
||||
github_username: user.login
|
||||
});
|
||||
}).catch((error) => {
|
||||
robot.logger.error(`[hubot-kredits] Error adding contributor:`, error);
|
||||
res.sendStatus(500);
|
||||
});
|
||||
} else {
|
||||
res.json({
|
||||
|
||||
Reference in New Issue
Block a user
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.
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?