Skip to content

Commit 51fa5e2

Browse files
res-odoobrboi
authored andcommitted
[IMP] mail: avoid cron job to send incoming call notification.
When we receive a notification to handle an incoming call we need to avoid to put then inside the job queue because we need to avoid the waiting times due of an urge amont of devices.
1 parent 41527b8 commit 51fa5e2

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

addons/mail/models/mail_thread.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3911,12 +3911,12 @@ def _web_push_get_partners_parameters(self, partner_ids):
39113911
return devices_su, None, None
39123912
return devices_su.search([("partner_id", "in", partner_ids)]), vapid_private_key, vapid_public_key
39133913

3914-
def _web_push_send_notification(self, devices, private_key, public_key, payload_by_lang=None, payload=None):
3914+
def _web_push_send_notification(self, devices, private_key, public_key, payload_by_lang=None, payload=None, force_direct_send=False):
39153915
"""
39163916
:param payload: JSON serializable dict following the notification api specs https://notifications.spec.whatwg.org/#api
39173917
:param payload_by_lang a dict mapping payload by lang, either this or payload must be provided
39183918
"""
3919-
if len(devices) < MAX_DIRECT_PUSH:
3919+
if len(devices) < MAX_DIRECT_PUSH or force_direct_send is True:
39203920
session = Session()
39213921
devices_to_unlink = set()
39223922
for device in devices:

addons/mail/models/res_users.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ def _get_current_persona(self):
670670
return (self.env["res.users"], self.env["mail.guest"]._get_guest_from_context())
671671
return (self.env.user, self.env["mail.guest"])
672672

673-
def _webpush_notification(self, body, model, res_id, icon, title='Odoo', author=None, extra_payload=None):
673+
def _webpush_notification(self, body, model, res_id, icon, title='Odoo', author=None, extra_payload=None, force_direct_send=False):
674674
if extra_payload is None:
675675
extra_payload = {}
676676
devices, private_key, public_key = self.env['mail.thread']._web_push_get_partners_parameters(self.partner_id.ids)
@@ -689,4 +689,4 @@ def _webpush_notification(self, body, model, res_id, icon, title='Odoo', author=
689689
},
690690
}
691691
} | extra_payload
692-
self.env['mail.thread']._web_push_send_notification(devices, private_key, public_key, payload=payload_webpush)
692+
self.env['mail.thread']._web_push_send_notification(devices, private_key, public_key, payload=payload_webpush, force_direct_send=force_direct_send)

0 commit comments

Comments
 (0)