only create preflight channel if channels are enabled

This commit is contained in:
Ryan Tharp 2020-07-02 05:26:47 +00:00
parent 7232d7f8f8
commit d0edde7452
1 changed files with 111 additions and 102 deletions

View File

@ -11,6 +11,7 @@ const config = require('./lib.config');
const logic = require('./logic');
const dialect = require('./lib.dialect');
const loki_crypt = require('./lib.loki_crypt');
const platformConfigUtil = require('./server/lib/lib.config');
// used for creating a default token for user 1
const ADN_SCOPES = 'basic stream write_post follow messages update_profile files export';
@ -85,6 +86,9 @@ const setup = (cache, dispatcher) => {
dialect.setup({ dispatcher });
storage.start(disk_config);
// only set up a channels, if channels enabled (open group mode)
if (platformConfigUtil.moduleEnabled('channels')) {
console.log('Open group mode detected')
dataAccess.getChannel(1, {}, async (err, chnl, meta) => {
if (err) console.error('channel 1 get err', err);
if (chnl && chnl.id) {
@ -176,13 +180,15 @@ const setup = (cache, dispatcher) => {
if (err3) console.error('addChannel err', err3);
if (chnl && chnl.id) {
console.log('channel', chnl.id, 'created');
}
addChannelNote(chnl.id);
// only can do this if we just created the userid 1
if (privKey) {
//console.log('need to create message 1!')
addChannelMessage(privKey, chnl.id);
}
} else {
console.error('Unable to set up channel')
}
});
});
});
@ -197,6 +203,9 @@ const setup = (cache, dispatcher) => {
}
});
*/
} else {
console.log('File server mode detected')
}
}
return { storage, logic, config, dialect, cache };