From 0037a0388636a92765a3bb16f81dd121ca33e513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 1 Nov 2019 21:01:46 -0400 Subject: [PATCH] fix: #8018, allow absolute urls in notification.path --- src/notifications.js | 4 ++++ src/user/digest.js | 9 ++++++--- src/views/emails/digest.tpl | 2 +- src/views/emails/notification.tpl | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/notifications.js b/src/notifications.js index e3d1a6b0db..69b3822e35 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -65,6 +65,9 @@ Notifications.getMultiple = async function (nids) { notifications.forEach(function (notification, index) { if (notification) { + if (notification.path && !notification.path.startsWith('http')) { + notification.path = nconf.get('relative_path') + notification.path; + } notification.datetimeISO = utils.toISOString(notification.datetime); if (notification.bodyLong) { @@ -168,6 +171,7 @@ async function pushToUids(uids, notification) { await async.eachLimit(uids, 3, function (uid, next) { emailer.send('notification', uid, { path: notification.path, + notification_url: notification.path.startsWith('http') ? notification.path : nconf.get('url') + notification.path, subject: utils.stripHTMLTags(notification.subject || '[[notifications:new_notification]]'), intro: utils.stripHTMLTags(notification.bodyShort), body: notification.bodyLong || '', diff --git a/src/user/digest.js b/src/user/digest.js index 7fdfa764cb..e35db90b49 100644 --- a/src/user/digest.js +++ b/src/user/digest.js @@ -81,9 +81,12 @@ Digest.send = async function (data) { return; } - notifications.forEach(function (notification) { - if (notification.image && !notification.image.startsWith('http')) { - notification.image = nconf.get('url') + notification.image; + notifications.forEach(function (n) { + if (n.image && !n.image.startsWith('http')) { + n.image = nconf.get('base_url') + n.image; + } + if (n.path) { + n.notification_url = n.path.startsWith('http') ? n.path : nconf.get('base_url') + n.path; } }); diff --git a/src/views/emails/digest.tpl b/src/views/emails/digest.tpl index 1f1de51d4e..424748406b 100644 --- a/src/views/emails/digest.tpl +++ b/src/views/emails/digest.tpl @@ -33,7 +33,7 @@ -

{notifications.bodyShort}

+

{notifications.bodyShort}

diff --git a/src/views/emails/notification.tpl b/src/views/emails/notification.tpl index c7437a7432..f39eafc983 100644 --- a/src/views/emails/notification.tpl +++ b/src/views/emails/notification.tpl @@ -30,7 +30,7 @@
- + [[email:notif.cta-{notification.cta-type}]] →