Added support for array of altmessaging.

This commit is contained in:
Ylian Saint-Hilaire 2021-02-08 17:53:35 -08:00
parent 45e51d8fb3
commit f7300b8b5b
2 changed files with 11 additions and 8 deletions

View File

@ -459,7 +459,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
}
if (matchingDomains.length > 0) { serverinfo.amtAcmFqdn = matchingDomains; }
}
if ((typeof domain.altmessenging == 'object') && (typeof domain.altmessenging.name == 'string') && (typeof domain.altmessenging.url == 'string')) { serverinfo.altmessenging = { name: domain.altmessenging.name, url: domain.altmessenging.url }; }
if ((typeof domain.altmessenging == 'object') && (typeof domain.altmessenging.name == 'string') && (typeof domain.altmessenging.url == 'string')) { serverinfo.altmessenging = [{ name: domain.altmessenging.name, url: domain.altmessenging.url }]; }
if (Array.isArray(domain.altmessenging)) { serverinfo.altmessenging = []; for (var i in domain.altmessenging) { if ((typeof domain.altmessenging[i] == 'object') && (typeof domain.altmessenging[i].name == 'string') && (typeof domain.altmessenging[i].url == 'string')) { serverinfo.altmessenging.push({ name: domain.altmessenging[i].name, url: domain.altmessenging[i].url }); } } }
serverinfo.https = true;
serverinfo.redirport = args.redirport;

View File

@ -5980,7 +5980,9 @@
if ((meshrights & 8) && ((connectivity & 1) || ((node.pmt == 1) && ((features2 & 2) != 0)))) { x += '<input type=button value="' + "Message" + '" title="' + "Display a text message on the remote device" + '" onclick=deviceMessageFunction() />'; }
//if ((connectivity & 1) && (meshrights & 8) && (node.agent.id < 5)) { x += '<input type=button value=Toast title="' + "Display a text message of the remote device" + '" onclick=deviceToastFunction() />'; }
if ((meshrights & 8) && (connectivity & 1) || ((node.pmt == 1) && ((features2 & 2) != 0))) { x += '<input type=button value="' + "Chat" + '" title="' + "Open chat window to this computer" + '" onclick=deviceChat(event) />'; }
if ((serverinfo != null) && (serverinfo.altmessenging != null) && (meshrights & 8) && (connectivity & 1)) { x += '<input type=button value="' + EscapeHtml(serverinfo.altmessenging.name) + '" onclick=altDeviceChat(event) />'; }
if ((serverinfo != null) && (serverinfo.altmessenging != null) && (meshrights & 8) && (connectivity & 1)) {
for (var i in serverinfo.altmessenging) { x += '<input type=button value="' + EscapeHtml(serverinfo.altmessenging[i].name) + '" onclick=altDeviceChat(event,' + i + ') />'; }
}
if ((serverinfo.guestdevicesharing !== false) && (node.agent != null) && (node.agent.caps & 3) && (connectivity & 1) && ((meshrights & 0x80008) == 0x80008) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 0x1000) == 0))) { x += '<input type=button value="' + "Share" + '" title="' + "Create a link to share this device with a guest" + '" onclick=showShareDevice() />'; }
// Custom UI
@ -6315,9 +6317,9 @@
meshserver.send({ action: 'meshmessenger', nodeid: decodeURIComponent(currentNode._id) });
}
function altDeviceChat(e) {
function altDeviceChat(e, i) {
if (xxdialogMode) return;
var url = serverinfo.altmessenging.url.split('{0}').join(currentNode._id.split('/').join('-'));
var url = serverinfo.altmessenging[i].url.split('{0}').join(currentNode._id.split('/').join('-'));
meshserver.send({ action: 'msg', type: 'openUrl', nodeid: currentNode._id, url: url });
safeNewWindow(url, 'altmessenger:' + currentNode._id, 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=560');
}
@ -11819,12 +11821,12 @@
return false;
}
function altUserChat(e, userid, name) {
function altUserChat(e, userid, name, i) {
if (xxdialogMode) return;
haltEvent(e);
var url = serverinfo.altmessenging.url.split('{0}').join(userid.split('/').join('-'));
var url = serverinfo.altmessenging[i].url.split('{0}').join(userid.split('/').join('-'));
safeNewWindow(url, 'altmessenger:' + userid);
meshserver.send({ action: 'notifyuser', userid: decodeURIComponent(userid), msg: serverinfo.altmessenging.name, msgid: 11, url: url });
meshserver.send({ action: 'notifyuser', userid: decodeURIComponent(userid), msg: serverinfo.altmessenging[i].name, msgid: 11, url: url });
return false;
}
@ -12732,7 +12734,7 @@
if (!self && (activeSessions > 0)) {
x += '<input type=button value="' + "Notify" + '" title="' + "Send user notification" + '" onclick=showUserAlertDialog(event,"' + encodeURIComponentEx(user._id) + '") />';
x += '<input type=button value="' + "Chat" + '" title="' + "Chat" + '" onclick=userChat(event,"' + encodeURIComponentEx(user._id) + '","' + encodeURIComponentEx(user.name) + '") />';
if ((serverinfo != null) && (serverinfo.altmessenging != null)) { x += '<input type=button value="' + EscapeHtml(serverinfo.altmessenging.name) + '" onclick=altUserChat(event,"' + encodeURIComponentEx(user._id) + '","' + encodeURIComponentEx(user.name) + '") />'; }
if ((serverinfo != null) && (serverinfo.altmessenging != null)) { for (var i in serverinfo.altmessenging) { x += '<input type=button value="' + EscapeHtml(serverinfo.altmessenging[i].name) + '" onclick=altUserChat(event,"' + encodeURIComponentEx(user._id) + '","' + encodeURIComponentEx(user.name) + '",' + i + ') />'; } }
}
// Setup the panel