Skip to content

A platform for community discussion. Free, open, simple.

FIX: Consolidated like notifications links to wrong user on user page.

Guo Xiang Tanf8db93df5fb9
diff --git a/app/assets/javascripts/discourse/widgets/notification-item.js.es6 b/app/assets/javascripts/discourse/widgets/notification-item.js.es6
index bd43d2d8560..93e1315031f 100644
--- a/app/assets/javascripts/discourse/widgets/notification-item.js.es6
+++ b/app/assets/javascripts/discourse/widgets/notification-item.js.es6
@@ -64,9 +64,11 @@ createWidget("notification-item", {
if (attrs.notification_type === LIKED_CONSOLIDATED_TYPE) {
return userPath(
- `${
- this.currentUser.username
- }/notifications/likes-received?acting_username=${data.display_username}`
+ `${this.attrs.username ||
+ this.currentUser
+ .username}/notifications/likes-received?acting_username=${
+ data.display_username
+ }`
);
}
diff --git a/app/assets/javascripts/discourse/widgets/user-notifications-large.js.es6 b/app/assets/javascripts/discourse/widgets/user-notifications-large.js.es6
index d8a8c699b1b..11e87532be0 100644
--- a/app/assets/javascripts/discourse/widgets/user-notifications-large.js.es6
+++ b/app/assets/javascripts/discourse/widgets/user-notifications-large.js.es6
@@ -22,6 +22,11 @@ createWidget("large-notification-item", {
export default createWidget("user-notifications-large", {
html(attrs) {
const notifications = attrs.notifications;
- return notifications.map(n => this.attach("large-notification-item", n));
+ const username = notifications.findArgs.username;
+
+ return notifications.map(n => {
+ n.username = username;
+ return this.attach("large-notification-item", n);
+ });
}
});
diff --git a/test/javascripts/acceptance/user-test.js.es6 b/test/javascripts/acceptance/user-test.js.es6
index 8a05a9367ef..253f126bb57 100644
--- a/test/javascripts/acceptance/user-test.js.es6
+++ b/test/javascripts/acceptance/user-test.js.es6
@@ -15,6 +15,16 @@ QUnit.test("Messages", async assert => {
QUnit.test("Notifications", async assert => {
await visit("/u/eviltrout/notifications");
assert.ok($("body.user-notifications-page").length, "has the body class");
+
+ await visit("/u/test/notifications");
+
+ const $links = find(".item.notification a");
+
+ assert.ok(
+ $links[1].href.includes(
+ "/u/test/notifications/likes-received?acting_username=aquaman"
+ )
+ );
});
QUnit.test("Root URL - Viewing Self", async assert => {
diff --git a/test/javascripts/helpers/create-pretender.js.es6 b/test/javascripts/helpers/create-pretender.js.es6
index 02f84cab4c2..d4e34d5df3f 100644
--- a/test/javascripts/helpers/create-pretender.js.es6
+++ b/test/javascripts/helpers/create-pretender.js.es6
@@ -79,6 +79,12 @@ export default function() {
return response(json);
});
+ this.get("/u/test.json", () => {
+ const json = fixturesByUrl["/u/eviltrout.json"];
+ json.user.username = "test";
+ return response(json);
+ });
+
this.get("/u/eviltrout/summary.json", () => {
return response({
user_summary: {