summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/models/messaging_notification_handler
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2020-08-24 10:37:36 +0000
committerSébastien Theys <seb@odoo.com>2020-08-24 13:21:43 +0000
commit9b80f9e7f1fdec3a7b74daed621b94f96716559f (patch)
tree2731bb74061b315118be397f49f89c07a0d11967 /addons/mail/static/src/models/messaging_notification_handler
parent40155abb42b43dc1b2339129a1c1bb6c9f6fd924 (diff)
[FIX] mail, im_livechat: ignore notifications for unknown channels
Inserting channels and handling notifications for channels that have not been properly initialized through the `channel_info` leads to issues due to incomplete data that is not properly handled, such as bad correspondent, missing uuid, inconsistent name, etc. Moreover it doesn't make sense functionally to handle notifications such as typing status if the channel isn't going to be displayed. PR: #56243 Part of task-2323670 X-original-commit: 75070665060d64fe7b532aac4fc8e8410381b083
Diffstat (limited to 'addons/mail/static/src/models/messaging_notification_handler')
-rw-r--r--addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js32
1 files changed, 17 insertions, 15 deletions
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 7bd0e16d6f2..6764f28ceb4 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
@@ -144,9 +144,10 @@ function factory(dependencies) {
last_message_id,
partner_id,
}) {
- const channel = this.env.models['mail.thread'].find(thread =>
- thread.id === channelId && thread.model === 'mail.channel'
- );
+ const channel = this.env.models['mail.thread'].findFromIdentifyingData({
+ id: channelId,
+ model: 'mail.channel',
+ });
if (!channel) {
// for example seen from another browser, the current one has no
// knowledge of the channel
@@ -198,10 +199,10 @@ function factory(dependencies) {
const message = this.env.models['mail.message'].insert(convertedData);
// join the corresponding channel if necessary
- const channel = this.env.models['mail.thread'].find(thread =>
- thread.id === channelId &&
- thread.model === 'mail.channel'
- );
+ const channel = this.env.models['mail.thread'].findFromIdentifyingData({
+ id: channelId,
+ model: 'mail.channel',
+ });
if (!channel || !channel.isPinned) {
this.env.models['mail.thread'].joinChannel(channelId);
}
@@ -275,9 +276,10 @@ function factory(dependencies) {
last_message_id,
partner_id,
}) {
- const channel = this.env.models['mail.thread'].find(thread =>
- thread.id === channelId && thread.model === 'mail.channel'
- );
+ const channel = this.env.models['mail.thread'].findFromIdentifyingData({
+ id: channelId,
+ model: 'mail.channel',
+ });
if (!channel) {
// for example seen from another browser, the current one has no
// knowledge of the channel
@@ -327,10 +329,13 @@ function factory(dependencies) {
is_typing,
partner_id,
}) {
- const channel = this.env.models['mail.thread'].insert({
+ const channel = this.env.models['mail.thread'].findFromIdentifyingData({
id: channelId,
model: 'mail.channel',
});
+ if (!channel) {
+ return;
+ }
const partner = this.env.models['mail.partner'].insert({ id: partner_id });
if (partner === this.env.messaging.currentPartner) {
// Ignore management of current partner is typing notification.
@@ -444,10 +449,7 @@ function factory(dependencies) {
_handleNotificationPartnerChannel(data) {
const convertedData = this.env.models['mail.thread'].convertData(data);
- let channel = this.env.models['mail.thread'].find(thread =>
- thread.id === convertedData.id &&
- thread.model === 'mail.channel'
- );
+ let channel = this.env.models['mail.thread'].findFromIdentifyingData(convertedData);
const wasCurrentPartnerMember = (
channel &&
channel.members.includes(this.env.messaging.currentPartner)