diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index 33bf3c25af9..3cc5bc38ee1 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -1135,6 +1135,7 @@ class Message(models.Model): the message was successfully sent or if an exception or bounce occurred. """ return [{ + 'author': {'id': message.author_id.id, 'type': "partner"} if message.author_id else False, 'id': message.id, 'res_id': message.res_id, 'model': message.model, diff --git a/addons/mail/static/src/core/common/mail_core_common_service.js b/addons/mail/static/src/core/common/mail_core_common_service.js index 82f28c06127..86d78de540b 100644 --- a/addons/mail/static/src/core/common/mail_core_common_service.js +++ b/addons/mail/static/src/core/common/mail_core_common_service.js @@ -49,13 +49,7 @@ export class MailCoreCommon { } }); this.busService.subscribe("mail.message/notification_update", (payload) => { - // implicit: failures are sent by the server at - // initialization only if the current partner is - // author of the message - this.store.Message.insert( - payload.elements.map((data) => ({ ...data, author: this.store.self })), - { html: true } - ); + this.store.Message.insert(payload.elements, { html: true }); }); this.busService.subscribe("mail.message/toggle_star", (payload) => { const { message_ids: messageIds, starred } = payload; diff --git a/addons/mail/static/src/core/web/mail_core_web_service.js b/addons/mail/static/src/core/web/mail_core_web_service.js index 158fdaa9700..6d83009d600 100644 --- a/addons/mail/static/src/core/web/mail_core_web_service.js +++ b/addons/mail/static/src/core/web/mail_core_web_service.js @@ -21,13 +21,7 @@ export class MailCoreWeb { setup() { this.messagingService.isReady.then(() => { this.rpc("/mail/load_message_failures", {}, { silent: true }).then((messages) => { - // implicit: failures are sent by the server at - // initialization only if the current partner is - // author of the message - this.store.Message.insert( - messages.map((m) => ({ ...m, author: this.store.user })), - { html: true } - ); + this.store.Message.insert(messages, { html: true }); this.store.failures.sort((f1, f2) => f2.lastMessage?.id - f1.lastMessage?.id); }); this.busService.subscribe("mail.activity/updated", (payload) => { diff --git a/addons/mail/static/tests/helpers/mock_server/models/mail_message.js b/addons/mail/static/tests/helpers/mock_server/models/mail_message.js index 28801b00c70..923275289e5 100644 --- a/addons/mail/static/tests/helpers/mock_server/models/mail_message.js +++ b/addons/mail/static/tests/helpers/mock_server/models/mail_message.js @@ -387,6 +387,7 @@ patch(MockServer.prototype, { notifications.map((notification) => notification.id) ); return { + author: message.author_id ? { id: message.author_id, type: "partner" } : false, body: message.body, date: message.date, id: message.id,