MDL-62889 message_popup: only add redirecturl if it exists
authorMark Nelson <markn@moodle.com>
Wed, 11 Jul 2018 04:54:46 +0000 (12:54 +0800)
committerMark Nelson <markn@moodle.com>
Tue, 17 Jul 2018 03:44:41 +0000 (11:44 +0800)
We allow notifications to have a null value for the 'contexturl'.
In this case we should not be appending a 'redirecturl' param to
the URL when it is going to be empty.

message/output/popup/amd/build/notification_popover_controller.min.js
message/output/popup/amd/src/notification_popover_controller.js

index b241a56..2222a85 100644 (file)
Binary files a/message/output/popup/amd/build/notification_popover_controller.min.js and b/message/output/popup/amd/build/notification_popover_controller.min.js differ
index 9aa7630..944f8a9 100644 (file)
@@ -223,10 +223,13 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str', 'core/url',
             });
 
             // Link to mark read page before loading the actual link.
-            notification.contexturl = URL.relativeUrl('message/output/popup/mark_notification_read.php', {
-                notificationid: notification.id,
-                redirecturl: notification.contexturl
-            });
+            var notificationurlparams = {
+                notificationid: notification.id
+            };
+            if (notification.contexturl) {
+                notificationurlparams.redirecturl = notification.contexturl;
+            }
+            notification.contexturl = URL.relativeUrl('message/output/popup/mark_notification_read.php', notificationurlparams);
 
             var promise = Templates.render('message_popup/notification_content_item', notification)
             .then(function(html, js) {