Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions mail_gateway/models/mail_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


from odoo import api, fields, models
from odoo.tests import RecordCapturer

from odoo.addons.mail.tools.discuss import Store

Expand Down Expand Up @@ -118,10 +117,10 @@ def _send_to_gateway_thread(self, gateway_channel_id):
gateway_channel_id.gateway_token
)
channel = self.env["discuss.channel"].browse(chat_id)
with RecordCapturer(
self.env["mail.notification"], [("gateway_channel_id", "=", channel.id)]
) as capt:
channel.message_post(**self._get_gateway_thread_message_vals())
messages = channel.message_post(**self._get_gateway_thread_message_vals())
notification = messages.notification_ids.filtered(
lambda n: n.gateway_channel_id == channel
)
if not self.gateway_type:
self.gateway_type = gateway_channel_id.gateway_id.gateway_type
notification_vals = {
Expand All @@ -131,7 +130,6 @@ def _send_to_gateway_thread(self, gateway_channel_id):
"notification_type": "gateway",
"gateway_type": gateway_channel_id.gateway_id.gateway_type,
}
notification = capt.records
if notification:
# Set the same gateway_message_id for both notifications.
# When the webhook is received, both notifications must be updated.
Expand Down
Loading