Merge branch 'hotfix/21.56.9' into master
[gitter.git] / server / api / private / check-group-uri.js
blob5bf9546c8dab3bfd26d58c308538e789f22669d1
1 'use strict';
3 var groupUriChecker = require('gitter-web-groups/lib/group-uri-checker');
5 function checkGroupUri(req, res, next) {
6 return groupUriChecker(req.user, req.query.uri)
7 .then(function(info) {
8 if (info.allowCreate) {
9 res.send({
10 type: info.type
11 });
12 // This is clearly a GitHub permsisions issue (#github-uri-split)
13 } else if (
14 !info.localUriExists &&
15 (info.type === 'GH_ORG' || info.type === 'GH_REPO' || info.type === 'GH_USER')
16 ) {
17 res.sendStatus(403);
18 } else {
19 res.sendStatus(409);
22 .catch(next);
25 module.exports = checkGroupUri;