From 089bcd6a09b4cb834af8e55cc510db0ad71187b6 Mon Sep 17 00:00:00 2001 From: Leonardo Cabeza Date: Thu, 18 Oct 2018 23:00:38 -0500 Subject: [PATCH] =?UTF-8?q?(Agrega)=20Autenticaci=C3=B3n=20de=20github=20p?= =?UTF-8?q?ara=20utilizar=20api=20(#142)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.sample.js | 3 +++ src/index.js | 4 ++-- src/utils/github.js | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config/config.sample.js b/config/config.sample.js index 54891e9..53c853e 100644 --- a/config/config.sample.js +++ b/config/config.sample.js @@ -34,6 +34,9 @@ const config = { id: process.env.twitterId || '41469246', hashtagMessage: '#ngVenezuelaTweet' }, + github: { + accessToken: process.env.githubAccessToken || 'GITHUB_ACCESS_TOKEN' + }, githubReleases: [ { name: 'angular', diff --git a/src/index.js b/src/index.js index 9031d1b..5a31bdb 100644 --- a/src/index.js +++ b/src/index.js @@ -132,7 +132,7 @@ const runMainProcess = () => { ) ); /** - * On any message check if api.ai has a respond to the message + * On any message check if api.ai has a response to the message */ bot .on('message', msg => @@ -192,7 +192,7 @@ const runMainProcess = () => { .on('newFeed', feed => blogUtility.checkAndSendBlogEntry(bot, feed)); }; -if (process.env.enironment !== 'development' && sentryDsnKey) { +if (process.env.environment !== 'development' && sentryDsnKey) { raven.config(sentryDsnKey).install(); raven.context(() => { runMainProcess(); diff --git a/src/utils/github.js b/src/utils/github.js index 14036d3..a68dedf 100644 --- a/src/utils/github.js +++ b/src/utils/github.js @@ -8,6 +8,7 @@ const gistCreated = require('./../../config/messages').gistCreated; const telegramLink = require('./../../config/config').community.telegram.link; const githubLink = require('./../../config/config').community.github; const gistRecommendation = require('./../../config/messages').gistRecommendation; +const githubToken = require('./../../config/config').integrations.github.accessToken; const sendMessage = require('./../utils/message').sendMessage; const commandUtility = require('./../utils/command'); @@ -112,6 +113,7 @@ const prepareAndSendGist = ( method: 'POST', headers: { 'Content-Type': 'application/json; charset=utf-8', + 'Authorization': `token ${githubToken}` }, body: JSON.stringify(body) }) @@ -134,7 +136,7 @@ const prepareAndSendGist = ( */ const checkGist = (bot, msgContext, redisClient, text = '', checkingForCode = true) => { commandUtility.verifyCommand(redisClient, GIST_COMMAND, msgContext.from.id) - .then((canExecuteCommand) => { + .then((canExecuteCommand) => { if (canExecuteCommand) { if (text === '' && msgContext.text.length >= MAX_LENGTH_GIST_TEXT) { if (checkingForCode) {