Finished up with channel rank/perms frontend.
This commit is contained in:
parent
edb4215929
commit
796bb033a7
22 changed files with 472 additions and 57 deletions
|
|
@ -18,20 +18,27 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
const config = require('../../config.json');
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler} = require('../utils/loggerUtils.js');
|
||||
const {exceptionHandler} = require('../utils/loggerUtils');
|
||||
const channelModel = require('../schemas/channel/channelSchema');
|
||||
const permissionModel = require('../schemas/permissionSchema');
|
||||
|
||||
//root index functions
|
||||
module.exports.get = async function(req, res){
|
||||
try{
|
||||
const chanName = (req.url.slice(1).replace('/settings',''));
|
||||
const channel = await channelModel.findOne({name: chanName});
|
||||
const chanDB = await channelModel.findOne({name: chanName});
|
||||
const reqRank = await chanDB.getChannelRank(req.session.user);
|
||||
|
||||
if(channel == null){
|
||||
await chanDB.populate("rankList.user");
|
||||
|
||||
//Take out the permissions doc id since we don't need it.
|
||||
delete chanDB.permissions._doc._id;
|
||||
|
||||
if(chanDB == null){
|
||||
throw new Error("Channel not found.");
|
||||
}
|
||||
|
||||
return res.render('channelSettings', {instance: config.instanceName, user: req.session.user, channel});
|
||||
return res.render('channelSettings', {instance: config.instanceName, user: req.session.user, channel: chanDB, reqRank, rankEnum: permissionModel.rankEnum});
|
||||
}catch(err){
|
||||
return exceptionHandler(res, err);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue