nodebb-plugin-web-push 0.7.8 → 0.7.10

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.
@@ -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([{ text: username, url: `/user/${userslug}` }, { text: '[[web-push:profile.label]]' }]),
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
- bodyLong: 'This is a test message sent from NodeBB',
108
+ // test notification shouldn't show any html chars
109
+ bodyLong: 'This is a &lt;bdi&gt;test&lt;/bdi&gt; 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 => validator.unescape(utils.stripHTMLTags(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.8",
3
+ "version": "0.7.10",
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.5"
46
+ "lint-staged": "17.0.8"
47
47
  },
48
48
  "dependencies": {
49
49
  "validator": "^13.12.0",
@@ -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
- var padding = '='.repeat((4 - (base64String.length % 4)) % 4);
87
- var base64 = (base64String + padding)
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
- var rawData = window.atob(base64);
92
- var outputArray = new Uint8Array(rawData.length);
91
+ const rawData = window.atob(base64);
92
+ const outputArray = new Uint8Array(rawData.length);
93
93
 
94
- for (var i = 0; i < rawData.length; ++i) {
94
+ for (let i = 0; i < rawData.length; ++i) {
95
95
  outputArray[i] = rawData.charCodeAt(i);
96
96
  }
97
97
  return outputArray;