Claim availability check #434

Merged
bones7242 merged 7 commits from claim-availability-check into master 2018-05-06 20:22:38 +02:00
Showing only changes of commit 9a7fdf4834 - Show all commits

View file

@ -10,6 +10,7 @@ const { handleErrorResponse } = require('../../../utils/errorHandlers.js');
const channelAvailability = ({ ip, originalUrl, params: { name } }, res) => { const channelAvailability = ({ ip, originalUrl, params: { name } }, res) => {
const gaStartTime = Date.now(); const gaStartTime = Date.now();
let name = `@${name}`;
checkChannelAvailability(name) checkChannelAvailability(name)
.then(isAvailable => { .then(isAvailable => {
let responseObject = { let responseObject = {
@ -17,9 +18,9 @@ const channelAvailability = ({ ip, originalUrl, params: { name } }, res) => {
data: isAvailable, data: isAvailable,
}; };
if (isAvailable) { if (isAvailable) {
responseObject['message'] = `That channel name is available` responseObject['message'] = `${name} is available`
} else { } else {
responseObject['message'] = `That channel is already in use` responseObject['message'] = `${name} is already in use`
} }
res.status(200).json(responseObject); res.status(200).json(responseObject);
sendGATimingEvent('end-to-end', 'channel name availability', name, gaStartTime, Date.now()); sendGATimingEvent('end-to-end', 'channel name availability', name, gaStartTime, Date.now());