remove slack completely and update help and pair actions
This commit is contained in:
@ -2,10 +2,8 @@ var Rx = require('rx'),
|
||||
Twit = require('twit'),
|
||||
async = require('async'),
|
||||
moment = require('moment'),
|
||||
Slack = require('node-slack'),
|
||||
request = require('request'),
|
||||
debug = require('debug')('freecc:cntr:resources'),
|
||||
|
||||
constantStrings = require('../utils/constantStrings.json'),
|
||||
bootcampJson = require('../utils/bootcamps.json'),
|
||||
secrets = require('../../config/secrets');
|
||||
@ -24,8 +22,6 @@ module.exports = function(app) {
|
||||
router.get('/api/trello', trelloCalls);
|
||||
router.get('/api/codepen/twitter/:screenName', twitter);
|
||||
router.get('/sitemap.xml', sitemap);
|
||||
router.post('/get-help', getHelp);
|
||||
router.post('/get-pair', getPair);
|
||||
router.get('/chat', chat);
|
||||
router.get('/coding-bootcamp-cost-calculator', bootcampCalculator);
|
||||
router.get('/coding-bootcamp-cost-calculator.json', bootcampCalculatorJson);
|
||||
@ -39,72 +35,9 @@ module.exports = function(app) {
|
||||
router.get('/unsubscribe/:email', unsubscribe);
|
||||
router.get('/unsubscribed', unsubscribed);
|
||||
router.get('/cats.json', getCats);
|
||||
router.get('/api/slack', slackInvite);
|
||||
|
||||
app.use(router);
|
||||
|
||||
function slackInvite(req, res, next) {
|
||||
if (req.user) {
|
||||
if (req.user.email) {
|
||||
var invite = {
|
||||
'email': req.user.email,
|
||||
'token': process.env.SLACK_KEY,
|
||||
'set_active': true
|
||||
};
|
||||
|
||||
var headers = {
|
||||
'User-Agent': 'Node Browser/0.0.1',
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
};
|
||||
|
||||
var options = {
|
||||
url: 'https://freecodecamp.slack.com/api/users.admin.invite',
|
||||
method: 'POST',
|
||||
headers: headers,
|
||||
form: invite
|
||||
};
|
||||
|
||||
request(options, function (error, response) {
|
||||
if (!error && response.statusCode === 200) {
|
||||
req.flash('success', {
|
||||
msg: 'We\'ve successfully requested an invite for you.' +
|
||||
' Please check your email and follow the ' +
|
||||
'instructions from Slack.'
|
||||
});
|
||||
req.user.sentSlackInvite = true;
|
||||
req.user.save(function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
return res.redirect('back');
|
||||
});
|
||||
} else {
|
||||
req.flash('errors', {
|
||||
msg: 'The invitation email did not go through for some reason.' +
|
||||
' Please try again or <a href=\'mailto:team@' +
|
||||
'freecodecamp.com?subject=' +
|
||||
'slack%20invite%20failed%20to%20send\'>' +
|
||||
'email us</a>.'
|
||||
});
|
||||
return res.redirect('back');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
req.flash('notice', {
|
||||
msg: 'Before we can send your Slack invite, we need your email ' +
|
||||
'address. Please update your profile information here.'
|
||||
});
|
||||
return res.redirect('/account');
|
||||
}
|
||||
} else {
|
||||
req.flash('notice', {
|
||||
msg: 'You need to sign in to Free Code Camp before ' +
|
||||
'we can send you a Slack invite.'
|
||||
});
|
||||
return res.redirect('/account');
|
||||
}
|
||||
}
|
||||
|
||||
function twitter(req, res, next) {
|
||||
// sends out random tweets about javascript
|
||||
var T = new Twit({
|
||||
@ -134,56 +67,6 @@ module.exports = function(app) {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function getHelp(req, res) {
|
||||
var userName = req.user.username;
|
||||
var code = req.body.payload.code ? '\n```\n' +
|
||||
req.body.payload.code + '\n```\n'
|
||||
: '';
|
||||
var challenge = req.body.payload.challenge;
|
||||
|
||||
slack.send({
|
||||
text: '*@' + userName + '* wants help with ' + challenge + '. ' +
|
||||
code + 'Hey, *@' + userName + '*, if no one helps you right ' +
|
||||
'away, try typing out your problem in detail to me. Like this: ' +
|
||||
'http://en.wikipedia.org/wiki/Rubber_duck_debugging',
|
||||
channel: '#help',
|
||||
username: 'Debuggy the Rubber Duck',
|
||||
'icon_url': 'https://pbs.twimg.com/profile_images/' +
|
||||
'3609875545/569237541c920fa78d78902069615caf.jpeg'
|
||||
});
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
|
||||
function getPair(req, res) {
|
||||
var userName = req.user.username;
|
||||
var challenge = req.body.payload.challenge;
|
||||
slack.send({
|
||||
text: [
|
||||
'Anyone want to pair with *@',
|
||||
userName,
|
||||
'* on ',
|
||||
challenge,
|
||||
'?\nMake sure you install Screen Hero here: ',
|
||||
'http://freecodecamp.com/field-guide/how-do-i-install-screenhero\n',
|
||||
'Then start your pair program session with *@',
|
||||
userName,
|
||||
'* by typing \"/hero @',
|
||||
userName,
|
||||
'\" into Slack.\n And *@',
|
||||
userName,
|
||||
'*, be sure to launch Screen Hero, then keep coding. ',
|
||||
'Another camper may pair with you soon.'
|
||||
].join(''),
|
||||
channel: '#letspair',
|
||||
username: 'Companion Cube',
|
||||
'icon_url':
|
||||
'https://lh3.googleusercontent.com/-f6xDPDV2rPE/AAAAAAAAAAI/' +
|
||||
'AAAAAAAAAAA/mdlESXQu11Q/photo.jpg'
|
||||
});
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
|
||||
function sitemap(req, res, next) {
|
||||
var appUrl = 'http://www.freecodecamp.com';
|
||||
var now = moment(new Date()).format('YYYY-MM-DD');
|
||||
@ -317,16 +200,6 @@ module.exports = function(app) {
|
||||
);
|
||||
}
|
||||
|
||||
function chat(req, res) {
|
||||
if (req.user && req.user.progressTimestamps.length > 5) {
|
||||
res.redirect('http://freecodecamp.slack.com');
|
||||
} else {
|
||||
res.render('resources/chat', {
|
||||
title: 'Watch us code live on Twitch.tv'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function bootcampCalculator(req, res) {
|
||||
res.render('resources/calculator', {
|
||||
title: 'Coding Bootcamp Cost Calculator',
|
||||
@ -338,6 +211,10 @@ module.exports = function(app) {
|
||||
res.send(bootcampJson);
|
||||
}
|
||||
|
||||
function chat(req, res) {
|
||||
res.redirect('https://gitter.im/FreeCodeCamp/FreeCodeCamp');
|
||||
}
|
||||
|
||||
function jobsForm(req, res) {
|
||||
res.render('resources/jobs-form', {
|
||||
title: 'Employer Partnership Form for Job Postings,' +
|
||||
|
Reference in New Issue
Block a user