Added support for array of altmessaging.
Ylian Saint-Hilaire committed
Feb 8, 2021 at 17:53 UTC
f7300b8b5b25e888048f764ab0781b8b004f4159
2 files changed
+11
-8
meshuser.js
+2
-1
@@ -459,7 +459,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
459
}
460
if (matchingDomains.length > 0) { serverinfo.amtAcmFqdn = matchingDomains; }
461
}
462
- 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 }; }
462
+ 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 }]; }
463
+ 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 }); } } }
464
serverinfo.https = true;
465
serverinfo.redirport = args.redirport;
466
views/default.handlebars
+9
-7
@@ -5980,7 +5980,9 @@
5980
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() />'; }
5981
//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() />'; }
5982
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) />'; }
5983
- if ((serverinfo != null) && (serverinfo.altmessenging != null) && (meshrights & 8) && (connectivity & 1)) { x += '<input type=button value="' + EscapeHtml(serverinfo.altmessenging.name) + '" onclick=altDeviceChat(event) />'; }
5983
+ if ((serverinfo != null) && (serverinfo.altmessenging != null) && (meshrights & 8) && (connectivity & 1)) {
5984
+ for (var i in serverinfo.altmessenging) { x += '<input type=button value="' + EscapeHtml(serverinfo.altmessenging[i].name) + '" onclick=altDeviceChat(event,' + i + ') />'; }
5985
+ }
5986
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() />'; }
5987
5988
// Custom UI
@@ -6315,9 +6317,9 @@
6317
meshserver.send({ action: 'meshmessenger', nodeid: decodeURIComponent(currentNode._id) });
6318
}
6319
6318
- function altDeviceChat(e) {
6320
+ function altDeviceChat(e, i) {
6321
if (xxdialogMode) return;
6320
- var url = serverinfo.altmessenging.url.split('{0}').join(currentNode._id.split('/').join('-'));
6322
+ var url = serverinfo.altmessenging[i].url.split('{0}').join(currentNode._id.split('/').join('-'));
6323
meshserver.send({ action: 'msg', type: 'openUrl', nodeid: currentNode._id, url: url });
6324
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');
6325
}
@@ -11819,12 +11821,12 @@
11821
return false;
11822
}
11823
11822
- function altUserChat(e, userid, name) {
11824
+ function altUserChat(e, userid, name, i) {
11825
if (xxdialogMode) return;
11826
haltEvent(e);
11825
- var url = serverinfo.altmessenging.url.split('{0}').join(userid.split('/').join('-'));
11827
+ var url = serverinfo.altmessenging[i].url.split('{0}').join(userid.split('/').join('-'));
11828
safeNewWindow(url, 'altmessenger:' + userid);
11827
- meshserver.send({ action: 'notifyuser', userid: decodeURIComponent(userid), msg: serverinfo.altmessenging.name, msgid: 11, url: url });
11829
+ meshserver.send({ action: 'notifyuser', userid: decodeURIComponent(userid), msg: serverinfo.altmessenging[i].name, msgid: 11, url: url });
11830
return false;
11831
}
11832
@@ -12732,7 +12734,7 @@
12734
if (!self && (activeSessions > 0)) {
12735
x += '<input type=button value="' + "Notify" + '" title="' + "Send user notification" + '" onclick=showUserAlertDialog(event,"' + encodeURIComponentEx(user._id) + '") />';
12736
x += '<input type=button value="' + "Chat" + '" title="' + "Chat" + '" onclick=userChat(event,"' + encodeURIComponentEx(user._id) + '","' + encodeURIComponentEx(user.name) + '") />';
12735
- if ((serverinfo != null) && (serverinfo.altmessenging != null)) { x += '<input type=button value="' + EscapeHtml(serverinfo.altmessenging.name) + '" onclick=altUserChat(event,"' + encodeURIComponentEx(user._id) + '","' + encodeURIComponentEx(user.name) + '") />'; }
12737
+ 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 + ') />'; } }
12738
}
12739
12740
// Setup the panel