Created
October 12, 2016 13:04
-
-
Save barisusakli/731bd32d43462f891fa3397d956efb5f to your computer and use it in GitHub Desktop.
create global moderators group if it doesn't exist and show it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
/*globals require, console, process */ | |
var nconf = require('nconf'); | |
var async = require('async'); | |
var winston = require('winston'); | |
nconf.file({ | |
file: 'config.json' | |
}); | |
var db = require('./src/database'); | |
db.init(function(err) { | |
if (err) { | |
console.log('NodeBB could not connect to your database. returned the following error: ' + err.message); | |
process.exit(); | |
} | |
createGlobalModeratorsGroup(function(err) { | |
if (err) { | |
console.log(err.message); | |
process.exit(); | |
} | |
console.log('group created'); | |
process.exit(); | |
}); | |
}); | |
function createGlobalModeratorsGroup(next) { | |
var groups = require('./src/groups'); | |
async.waterfall([ | |
function (next) { | |
groups.exists('Global Moderators', next); | |
}, | |
function (exists, next) { | |
if (exists) { | |
winston.info('Global Moderators group found, skipping creation!'); | |
return next(null, null); | |
} | |
groups.create({ | |
name: 'Global Moderators', | |
userTitle: 'Global Moderator', | |
description: 'Forum wide moderators', | |
hidden: 0, | |
private: 1, | |
disableJoinRequests: 1 | |
}, next); | |
}, | |
function (groupData, next) { | |
groups.show('Global Moderators', next); | |
} | |
], next); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment