nodebb-plugin-web-push 0.7.8 → 0.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/controllers.js +4 -1
- package/library.js +3 -2
- package/package.json +2 -2
- package/public/lib/settings.js +5 -5
package/lib/controllers.js
CHANGED
|
@@ -20,7 +20,10 @@ Controllers.renderSettings = async function (req, res) {
|
|
|
20
20
|
const payload = {
|
|
21
21
|
...res.locals.userData,
|
|
22
22
|
title: '[[web-push:profile.label]]',
|
|
23
|
-
breadcrumbs: helpers.buildBreadcrumbs([
|
|
23
|
+
breadcrumbs: helpers.buildBreadcrumbs([
|
|
24
|
+
{ text: username, url: `/user/${userslug}` },
|
|
25
|
+
{ text: '[[web-push:profile.label]]' },
|
|
26
|
+
]),
|
|
24
27
|
count,
|
|
25
28
|
};
|
|
26
29
|
|
package/library.js
CHANGED
|
@@ -105,7 +105,8 @@ plugin.addRoutes = async ({ router, middleware, helpers }) => {
|
|
|
105
105
|
const payload = await constructPayload({
|
|
106
106
|
nid: utils.generateUUID(),
|
|
107
107
|
bodyShort: 'Test notification',
|
|
108
|
-
|
|
108
|
+
// test notification shouln't show any html chars
|
|
109
|
+
bodyLong: 'This is a <bdi>test</bid> message sent from <strong>NodeBB</strong>',
|
|
109
110
|
path: `/me/web-push`,
|
|
110
111
|
}, req.uid, userLang);
|
|
111
112
|
await webPush.sendNotification(subscription, JSON.stringify(payload));
|
|
@@ -218,7 +219,7 @@ async function constructPayload(notification, uid, lang) {
|
|
|
218
219
|
const { nid, mergeId, bodyShort, bodyLong, path } = notification;
|
|
219
220
|
|
|
220
221
|
let [title, body] = await translator.translateKeys([bodyShort, bodyLong], lang);
|
|
221
|
-
([title, body] = [title, body].map(str =>
|
|
222
|
+
([title, body] = [title, body].map(str => utils.stripHTMLTags(utils.decodeHTMLEntities(str))));
|
|
222
223
|
title = `${dir === 'rtl' ? '\u200f' : '\u200e'}${title}`;
|
|
223
224
|
const tag = mergeId || nid;
|
|
224
225
|
const url = `${nconf.get('url')}${path}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodebb-plugin-web-push",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.9",
|
|
4
4
|
"description": "A plugin for adding native push notifications to NodeBB via the Web Push API.",
|
|
5
5
|
"main": "library.js",
|
|
6
6
|
"repository": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@eslint/js": "^10.0.1",
|
|
44
44
|
"eslint-config-nodebb": "^2.0.2",
|
|
45
45
|
"husky": "9.1.7",
|
|
46
|
-
"lint-staged": "17.0.
|
|
46
|
+
"lint-staged": "17.0.8"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"validator": "^13.12.0",
|
package/public/lib/settings.js
CHANGED
|
@@ -83,15 +83,15 @@ export async function init() {
|
|
|
83
83
|
// as value for applicationServerKey in pushManager.subscribe yet
|
|
84
84
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=802280
|
|
85
85
|
function urlBase64ToUint8Array(base64String) {
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
const padding = '='.repeat((4 - (base64String.length % 4)) % 4);
|
|
87
|
+
const base64 = (base64String + padding)
|
|
88
88
|
.replace(/-/g, '+')
|
|
89
89
|
.replace(/_/g, '/');
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
const rawData = window.atob(base64);
|
|
92
|
+
const outputArray = new Uint8Array(rawData.length);
|
|
93
93
|
|
|
94
|
-
for (
|
|
94
|
+
for (let i = 0; i < rawData.length; ++i) {
|
|
95
95
|
outputArray[i] = rawData.charCodeAt(i);
|
|
96
96
|
}
|
|
97
97
|
return outputArray;
|