[REF] mail: have author in notification formatter

So that `Message.insert()` in JS becomes trivial, as it doesn't have
to infer the author of message to current user.

closes odoo/odoo#139501

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Alexandre Kühn
2023-10-26 13:41:16 +00:00
parent eae6943021
commit 38d35c1ac6
4 changed files with 4 additions and 14 deletions
+1
View File
@@ -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,
@@ -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;
@@ -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) => {
@@ -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,