From 7bec33f578cfafa148a5fca27af0bc13fd550118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Mon, 24 Aug 2020 10:37:41 +0000 Subject: [PATCH] [FIX] mail: ignore broadcast notifications targeting another user This is typically not the case in production code, but it doesn't hurt to be safe. The main reason for the change however is that it causes issues in tests due to the easiest way to simulate notifications being to send them directly on the bus which is "listened to" no matter the target user. PR: #56243 Part of task-2323670 X-original-commit: 62e1e7fe39a7bed6ce70466a0aec645c7a0f299d --- .../messaging_notification_handler.js | 4 ++++ addons/mail/static/tests/helpers/mock_server.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js b/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js index 6764f28ceb4..49f07bc5423 100644 --- a/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js +++ b/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js @@ -77,6 +77,10 @@ function factory(dependencies) { channelId: id, }, data)); case 'res.partner': + if (id !== this.env.messaging.currentPartner.id) { + // ignore broadcast to other partners + return; + } return this._handleNotificationPartner(Object.assign({}, data)); default: console.warn(`mail.messaging_notification_handler: Unhandled notification "${model}"`); diff --git a/addons/mail/static/tests/helpers/mock_server.js b/addons/mail/static/tests/helpers/mock_server.js index d978d8e73f6..f57ca20a508 100644 --- a/addons/mail/static/tests/helpers/mock_server.js +++ b/addons/mail/static/tests/helpers/mock_server.js @@ -863,7 +863,7 @@ MockServer.include({ message_ids: messageIDs, type: "deletion", }; - const metaData = [dbName, 'res.partner']; + const metaData = [dbName, 'res.partner', this.currentPartnerId]; const notification = [metaData, notifData]; this._widget.call('bus_service', 'trigger', 'notification', [notification]); } else if (decision === 'accept') {