Ability to disable messenger at a global level

pull/1/head
yflory 6 years ago
parent 82cca49aef
commit 621fc9a897

@ -899,6 +899,7 @@ define([
Store.messenger = { Store.messenger = {
getFriendList: function (clientId, data, cb) { getFriendList: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.getFriendList(function (e, keys) { store.messenger.getFriendList(function (e, keys) {
cb({ cb({
error: e, error: e,
@ -907,6 +908,7 @@ define([
}); });
}, },
getMyInfo: function (clientId, data, cb) { getMyInfo: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.getMyInfo(function (e, info) { store.messenger.getMyInfo(function (e, info) {
cb({ cb({
error: e, error: e,
@ -915,6 +917,7 @@ define([
}); });
}, },
getFriendInfo: function (clientId, data, cb) { getFriendInfo: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.getFriendInfo(data, function (e, info) { store.messenger.getFriendInfo(data, function (e, info) {
cb({ cb({
error: e, error: e,
@ -923,6 +926,7 @@ define([
}); });
}, },
removeFriend: function (clientId, data, cb) { removeFriend: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.removeFriend(data, function (e, info) { store.messenger.removeFriend(data, function (e, info) {
cb({ cb({
error: e, error: e,
@ -931,11 +935,13 @@ define([
}); });
}, },
openFriendChannel: function (clientId, data, cb) { openFriendChannel: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.openFriendChannel(data, function (e) { store.messenger.openFriendChannel(data, function (e) {
cb({ error: e, }); cb({ error: e, });
}); });
}, },
getFriendStatus: function (clientId, data, cb) { getFriendStatus: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.getStatus(data, function (e, online) { store.messenger.getStatus(data, function (e, online) {
cb({ cb({
error: e, error: e,
@ -944,6 +950,7 @@ define([
}); });
}, },
getMoreHistory: function (clientId, data, cb) { 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) { store.messenger.getMoreHistory(data.curvePublic, data.sig, data.count, function (e, history) {
cb({ cb({
error: e, error: e,
@ -952,6 +959,7 @@ define([
}); });
}, },
sendMessage: function (clientId, data, cb) { sendMessage: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.sendMessage(data.curvePublic, data.content, function (e) { store.messenger.sendMessage(data.curvePublic, data.content, function (e) {
cb({ cb({
error: e, error: e,
@ -959,6 +967,7 @@ define([
}); });
}, },
setChannelHead: function (clientId, data, cb) { setChannelHead: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.setChannelHead(data.curvePublic, data.sig, function (e) { store.messenger.setChannelHead(data.curvePublic, data.sig, function (e) {
cb({ cb({
error: e error: e
@ -967,6 +976,7 @@ define([
}, },
execCommand: function (clientId, data, cb) { execCommand: function (clientId, data, cb) {
if (!store.messenger) { return void cb({error: 'Messenger is disabled'}); }
store.messenger.execCommand(data, cb); store.messenger.execCommand(data, cb);
} }
}; };
@ -1339,6 +1349,7 @@ define([
} }
}; };
var loadMessenger = function () { var loadMessenger = function () {
if (AppConfig.availablePadTypes.indexOf('contacts') === -1) { return; }
var messenger = store.messenger = Messenger.messenger(store); var messenger = store.messenger = Messenger.messenger(store);
messenger.on('message', function (message) { messenger.on('message', function (message) {
sendMessengerEvent('CONTACTS_MESSAGE', message); sendMessengerEvent('CONTACTS_MESSAGE', message);

@ -426,6 +426,7 @@ Messenger, MessengerUI, Messages) {
if (!config.metadataMgr) { if (!config.metadataMgr) {
throw new Error("You must provide a `metadataMgr` to display the chat"); throw new Error("You must provide a `metadataMgr` to display the chat");
} }
if (Config.availablePadTypes.indexOf('contacts') === -1) { return; }
var $content = $('<div>', {'class': 'cp-toolbar-chat-drawer'}); var $content = $('<div>', {'class': 'cp-toolbar-chat-drawer'});
$content.on('drop dragover', function (e) { $content.on('drop dragover', function (e) {
e.preventDefault(); e.preventDefault();

Loading…
Cancel
Save