From 7b21be10fd29ba3902f9bb72834e5fabbcda0b77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Tue, 4 Apr 2023 12:43:25 +0000 Subject: [PATCH] [FIX] mail: handle notification for guests not users MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some code in handle notification wrongly assumes `store.user` is set, as it reads `user.id`. This is correct when the user is authenticated as an internal user, but for guests this is incorrect. This commit adapt code of handling notifications so that `store.user` can be undefined for guests. Fix runbot issue 19978 closes odoo/odoo#117647 Signed-off-by: Sébastien Theys (seb) --- addons/mail/static/src/core/messaging_service.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mail/static/src/core/messaging_service.js b/addons/mail/static/src/core/messaging_service.js index dd20cdc66a0..5fbb9b5472c 100644 --- a/addons/mail/static/src/core/messaging_service.js +++ b/addons/mail/static/src/core/messaging_service.js @@ -235,7 +235,7 @@ export class Messaging { const command = rtcSessions[0][0]; this._updateRtcSessions(thread.id, sessionsData, command); - if (invitedByUserId !== this.store.user?.user.id) { + if (invitedByUserId && invitedByUserId !== this.store.user?.user?.id) { this.notificationService.add( sprintf(_t("You have been invited to #%s"), thread.displayName), { type: "info" } @@ -318,7 +318,7 @@ export class Messaging { } // move messages from Inbox to history const partnerIndex = message.needaction_partner_ids.find( - (p) => p === this.store.user.id + (p) => p === this.store.user?.id ); removeFromArray(message.needaction_partner_ids, partnerIndex); removeFromArrayWithPredicate( @@ -354,7 +354,7 @@ export class Messaging { // knowledge of the channel continue; } - if (this.store.user.id === partner_id) { + if (partner_id && this.store.user?.id === partner_id) { channel.serverLastSeenMsgBySelf = last_message_id; } const seenInfo = channel.seenInfos.find(