Unescape HTML entities in rich web push notifications in web UI (#7569)
parent
8a8a47892a
commit
ed4949c676
|
@ -1,5 +1,6 @@
|
||||||
import IntlMessageFormat from 'intl-messageformat';
|
import IntlMessageFormat from 'intl-messageformat';
|
||||||
import locales from './web_push_locales';
|
import locales from './web_push_locales';
|
||||||
|
import { unescape } from 'lodash';
|
||||||
|
|
||||||
const MAX_NOTIFICATIONS = 5;
|
const MAX_NOTIFICATIONS = 5;
|
||||||
const GROUP_TAG = 'tag';
|
const GROUP_TAG = 'tag';
|
||||||
|
@ -60,7 +61,7 @@ const formatMessage = (messageId, locale, values = {}) =>
|
||||||
(new IntlMessageFormat(locales[locale][messageId], locale)).format(values);
|
(new IntlMessageFormat(locales[locale][messageId], locale)).format(values);
|
||||||
|
|
||||||
const htmlToPlainText = html =>
|
const htmlToPlainText = html =>
|
||||||
html.replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n').replace(/<[^>]*>/g, '');
|
unescape(html.replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n').replace(/<[^>]*>/g, ''));
|
||||||
|
|
||||||
const handlePush = (event) => {
|
const handlePush = (event) => {
|
||||||
const { access_token, notification_id, preferred_locale, title, body, icon } = event.data.json();
|
const { access_token, notification_id, preferred_locale, title, body, icon } = event.data.json();
|
||||||
|
|
Loading…
Reference in New Issue