Added webpush to advanced config and schema.
Ylian Saint-Hilaire committed
Feb 10, 2021 at 01:31 UTC
ddf78e325c0f3d4877933220ea24f531a781ed37
3 files changed
+13
-3
meshcentral-config-schema.json
+9
@@ -65,6 +65,15 @@
65
"npmPath": { "type": "string" },
66
"npmProxy": { "type": "string", "format": "uri" },
67
"allowHighQualityDesktop": { "type": "boolean", "default": true },
68
+ "webPush": {
69
+ "type": "object",
70
+ "description": "When set with a valid email address, enables the MeshCentral web push notification feature. Allows administrators to send browser notifications to users even if they are not looking at the MeshCentral web site.",
71
+ "additionalProperties": false,
72
+ "properties": {
73
+ "email": { "type": "string", "description": "Server administrator email given to the FireFox and Chrome push notification services." }
74
+ },
75
+ "required": [ "email" ]
76
+ },
77
"publicPushNotifications": { "type": "boolean", "default": false, "description": "When true, this server uses MeshCentral.com a push notification relay for Android notifications. Push notifications work even if the Android app is not open." },
78
"desktopMultiplex": { "type": "boolean", "default": false, "description": "When true, enabled a server modules that efficiently splits a remote desktop stream to multiple browsers. Also allows slow browsers to not slow down the session for fast ones, this comes at the cost of extra server memory and processing for all remote desktop sessions." },
79
"userAllowedIP": { "type": [ "string", "array" ] },
public/serviceworker.js
+3
-3
@@ -2,12 +2,12 @@
2
self.addEventListener('push', function (event) {
3
if (event.data == null) return;
4
var json = event.data.json();
5
- const options = { body: json.body, icon: '/favicon-303x303.png', tag: json.url };
5
+ const options = { body: json.body, icon: '/favicon-303x303.png', data: { url: json.url } };
6
if (json.icon) { options.icon = '/images/notify/icons128-' + json.icon + '.png'; }
7
- self.registration.showNotification(json.title, options);
7
+ event.waitUntil(self.registration.showNotification(json.title, options));
8
});
9
10
self.addEventListener('notificationclick', function (event) {
11
event.notification.close();
12
- if ((event.notification.tag != null) && (event.notification.tag != '')) { event.waitUntil(self.clients.openWindow(event.notification.tag)); }
12
+ if ((event.notification.data.url != null) && (event.notification.data.url != '')) { event.waitUntil(self.clients.openWindow(event.notification.data.url)); }
13
});
\ No newline at end of file
sample-config-advanced.json
+1
@@ -51,6 +51,7 @@
51
"_npmPath": "c:\\npm.exe",
52
"_npmProxy": "http://1.2.3.4:80",
53
"_allowHighQualityDesktop": true,
54
+ "_webPush": { "email": "xxxxx@xxxxx.com" },
55
"_publicPushNotifications": true,
56
"_desktopMultiplex": true,
57
"_userAllowedIP": "127.0.0.1,192.168.1.0/24",