Node.js based forum software built for the modern web
fix: #8018, allow absolute urls in notification.path
Barış Soner Uşaklı0037a0388636
diff --git a/src/notifications.js b/src/notifications.jsindex 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.jsindex 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.tplindex 1f1de51d4e..424748406b 100644--- a/src/views/emails/digest.tpl+++ b/src/views/emails/digest.tpl@@ -33,7 +33,7 @@<!-- ENDIF notifications.image --></td><td style="padding: 16px; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; line-height: 16px; color: #333333;">- <p style="margin: 0;"><a style="text-decoration:none !important; text-decoration:none; color: #333333;" href="{url}{notifications.path}">{notifications.bodyShort}</a></p>+ <p style="margin: 0;"><a style="text-decoration:none !important; text-decoration:none; color: #333333;" href="{notifications.notification_url}">{notifications.bodyShort}</a></p></td></tr></table>diff --git a/src/views/emails/notification.tpl b/src/views/emails/notification.tplindex c7437a7432..f39eafc983 100644--- a/src/views/emails/notification.tpl+++ b/src/views/emails/notification.tpl@@ -30,7 +30,7 @@<table role="presentation" cellspacing="0" cellpadding="0" border="0" align="center" style="margin: auto;"><tr><td style="border-radius: 3px; background: #222222; text-align: center;" class="button-td">- <a href="{url}{path}" style="background: #222222; border: 15px solid #222222; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 13px; line-height: 1.1; text-align: center; text-decoration: none; display: block; border-radius: 3px; font-weight: bold;" class="button-a">+ <a href="{notification_url}" style="background: #222222; border: 15px solid #222222; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 13px; line-height: 1.1; text-align: center; text-decoration: none; display: block; border-radius: 3px; font-weight: bold;" class="button-a"><span style="color:#ffffff;" class="button-link">[[email:notif.cta<!-- IF notification.cta-type -->-{notification.cta-type}<!-- END -->]] →</span></a></td>