Merge pull request #1039 from expsa/samir-aladawi-send-all-notifications

[FIX] odex_web_app: firebase api body
This commit is contained in:
SamirLADOUI-sa 2024-09-08 15:25:33 +01:00 committed by GitHub
commit 76ac4559d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 9 deletions

View File

@ -45,9 +45,22 @@ class HrEmployee(models.Model):
'Authorization': 'Bearer %s' % (_get_access_token(temp_file_path))
}
body = json.dumps({
"to": self.fcm_token_web,
"direct_boot_ok": True,
"notification": notification
"message": {
"token": self.fcm_token_web,
"notification": notification,
"android": {
"notification": {
"sound": "default"
}
},
"apns": {
"payload": {
"aps": {
"sound": "default"
}
}
}
}
})
FCM_ENDPOINT = 'v1/projects/' + service_account_json['project_id'] + '/messages:send'
FCM_URL = BASE_URL + '/' + FCM_ENDPOINT

View File

@ -18,7 +18,6 @@ class MailActivity(models.Model):
if employee_id:
push_notify = employee_id.user_push_notification_web({
"title": activity_id.summary or activity_id.create_uid.name,
"body": notification_body,
"sound": "default"
"body": notification_body
})
return activity_ids

View File

@ -38,7 +38,6 @@ class Message(models.Model):
for employee_id in self.env['hr.employee'].sudo().search([('user_id', 'in', partner_ids.user_ids.ids)]):
push_notify = employee_id.user_push_notification_web({
"title": message.author_id.name,
"body": notification_body,
"sound": "default"
"body": notification_body
})
return messages

View File

@ -27,8 +27,7 @@ class MailThread(models.AbstractModel):
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,
"sound": "default"
"body": notification_body
})
return super(MailThread, self).message_post(message_type=message_type, **kwargs)