diff --git a/odex25_mobile/odex_web_app/models/hr_employee.py b/odex25_mobile/odex_web_app/models/hr_employee.py index 863dc1cbe..a7348d8df 100644 --- a/odex25_mobile/odex_web_app/models/hr_employee.py +++ b/odex25_mobile/odex_web_app/models/hr_employee.py @@ -23,10 +23,7 @@ class HrEmployee(models.Model): body = json.dumps({ "to": self.fcm_token_web, "direct_boot_ok": True, - "notification": { - "title": "Message", - "body": notification - } + "notification": notification }) try: respons = requests.post(url=url, data=body, headers=header) diff --git a/odex25_mobile/odex_web_app/models/mail_thread.py b/odex25_mobile/odex_web_app/models/mail_thread.py index 2f36083da..29c3782e3 100644 --- a/odex25_mobile/odex_web_app/models/mail_thread.py +++ b/odex25_mobile/odex_web_app/models/mail_thread.py @@ -14,9 +14,20 @@ class MailThread(models.AbstractModel): notification_body += '\n{} File(s)'.format(attachments) elif attachments: notification_body = '{} File(s)'.format(attachments) - + partners_to_notify = self.channel_partner_ids.filtered(lambda r: r.id != self.env.user.partner_id.id) - for employee_id in self.env['hr.employee'].sudo().search([('user_id', 'in', partners_to_notify.user_ids.ids)]): - push_notify = employee_id.user_push_notification_web(notification_body) + if self.public == 'private': + for employee_id in self.env['hr.employee'].sudo().search([('user_id', 'in', partners_to_notify.user_ids.ids)]): + custom_title = self.channel_last_seen_partner_ids.filtered(lambda r: r.partner_id.id == employee_id.user_id.partner_id.id) + push_notify = employee_id.user_push_notification_web({ + "title": custom_title.custom_channel_name or self.env.user.partner_id.name, + "body": notification_body + }) + else: + for employee_id in self.env['hr.employee'].sudo().search([('user_id', 'in', partners_to_notify.user_ids.ids)]): + push_notify = employee_id.user_push_notification_web({ + "title": self.display_name, + "body": notification_body + }) return super(MailThread, self).message_post(message_type=message_type, **kwargs) \ No newline at end of file