2018-04-27 18:54:36 +02:00
|
|
|
const db = require('../../../../models');
|
2018-04-27 08:42:22 +02:00
|
|
|
|
|
|
|
const checkChannelAvailability = (name) => {
|
|
|
|
return db.Channel
|
|
|
|
.findAll({
|
|
|
|
where: { channelName: name },
|
|
|
|
})
|
|
|
|
.then(result => {
|
|
|
|
if (result.length >= 1) {
|
|
|
|
throw new Error('That channel has already been claimed');
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
throw error;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = checkChannelAvailability;
|