From 621fc9a8970a8a8d93e91a41406f82407f4cc72e Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 12 Sep 2018 14:51:37 +0200 Subject: [PATCH] Ability to disable messenger at a global level --- www/common/outer/async-store.js | 11 +++++++++++ www/common/toolbar3.js | 1 + 2 files changed, 12 insertions(+) diff --git a/www/common/outer/async-store.js b/www/common/outer/async-store.js index eebda59ff..561a36c95 100644 --- a/www/common/outer/async-store.js +++ b/www/common/outer/async-store.js @@ -899,6 +899,7 @@ define([ Store.messenger = { getFriendList: function (clientId, data, cb) { + if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); } store.messenger.getFriendList(function (e, keys) { cb({ error: e, @@ -907,6 +908,7 @@ define([ }); }, getMyInfo: function (clientId, data, cb) { + if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); } store.messenger.getMyInfo(function (e, info) { cb({ error: e, @@ -915,6 +917,7 @@ define([ }); }, getFriendInfo: function (clientId, data, cb) { + if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); } store.messenger.getFriendInfo(data, function (e, info) { cb({ error: e, @@ -923,6 +926,7 @@ define([ }); }, removeFriend: function (clientId, data, cb) { + if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); } store.messenger.removeFriend(data, function (e, info) { cb({ error: e, @@ -931,11 +935,13 @@ define([ }); }, openFriendChannel: function (clientId, data, cb) { + if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); } store.messenger.openFriendChannel(data, function (e) { cb({ error: e, }); }); }, getFriendStatus: function (clientId, data, cb) { + if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); } store.messenger.getStatus(data, function (e, online) { cb({ error: e, @@ -944,6 +950,7 @@ define([ }); }, getMoreHistory: function (clientId, data, cb) { + if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); } store.messenger.getMoreHistory(data.curvePublic, data.sig, data.count, function (e, history) { cb({ error: e, @@ -952,6 +959,7 @@ define([ }); }, sendMessage: function (clientId, data, cb) { + if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); } store.messenger.sendMessage(data.curvePublic, data.content, function (e) { cb({ error: e, @@ -959,6 +967,7 @@ define([ }); }, setChannelHead: function (clientId, data, cb) { + if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); } store.messenger.setChannelHead(data.curvePublic, data.sig, function (e) { cb({ error: e @@ -967,6 +976,7 @@ define([ }, execCommand: function (clientId, data, cb) { + if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); } store.messenger.execCommand(data, cb); } }; @@ -1339,6 +1349,7 @@ define([ } }; var loadMessenger = function () { + if (AppConfig.availablePadTypes.indexOf('contacts') === -1) { return; } var messenger = store.messenger = Messenger.messenger(store); messenger.on('message', function (message) { sendMessengerEvent('CONTACTS_MESSAGE', message); diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js index a9fab999f..621aea0f8 100644 --- a/www/common/toolbar3.js +++ b/www/common/toolbar3.js @@ -426,6 +426,7 @@ Messenger, MessengerUI, Messages) { if (!config.metadataMgr) { throw new Error("You must provide a `metadataMgr` to display the chat"); } + if (Config.availablePadTypes.indexOf('contacts') === -1) { return; } var $content = $('
', {'class': 'cp-toolbar-chat-drawer'}); $content.on('drop dragover', function (e) { e.preventDefault();