Skip to content

Commit 567a325

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 4ce35f9 commit 567a325

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
@@ -3910,12 +3910,12 @@ def _web_push_get_partners_parameters(self, partner_ids):
39103910
return devices_su, None, None
39113911
return devices_su.search([("partner_id", "in", partner_ids)]), vapid_private_key, vapid_public_key
39123912

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

addons/mail/models/res_users.py

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

672-
def _webpush_notification(self, body, model, res_id, icon, title='Odoo', author=None, extra_payload=None):
672+
def _webpush_notification(self, body, model, res_id, icon, title='Odoo', author=None, extra_payload=None, force_direct_send=False):
673673
if extra_payload is None:
674674
extra_payload = {}
675675
devices, private_key, public_key = self.env['mail.thread']._web_push_get_partners_parameters(self.partner_id.ids)
@@ -688,4 +688,4 @@ def _webpush_notification(self, body, model, res_id, icon, title='Odoo', author=
688688
},
689689
}
690690
} | extra_payload
691-
self.env['mail.thread']._web_push_send_notification(devices, private_key, public_key, payload=payload_webpush)
691+
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)