diff --git a/frappe/integrations/doctype/push_notification_settings/push_notification_settings.json b/frappe/integrations/doctype/push_notification_settings/push_notification_settings.json index 2446ba760f..da1d6373a8 100644 --- a/frappe/integrations/doctype/push_notification_settings/push_notification_settings.json +++ b/frappe/integrations/doctype/push_notification_settings/push_notification_settings.json @@ -3,6 +3,7 @@ "allow_rename": 1, "beta": 1, "creation": "2024-01-04 11:36:08.013039", + "description": "Enabling this will register your site on a central relay server to send push notifications for all installed apps through Firebase Cloud Messaging. This server only stores user tokens and error logs, and no messages are saved.", "doctype": "DocType", "engine": "InnoDB", "field_order": [ @@ -28,14 +29,12 @@ { "fieldname": "api_key", "fieldtype": "Data", - "label": "API Key", - "read_only": 1 + "label": "API Key" }, { "fieldname": "api_secret", "fieldtype": "Password", - "label": "API Secret", - "read_only": 1 + "label": "API Secret" }, { "description": "Enabling this will register your site on a central relay server to send push notifications for all installed apps through Firebase Cloud Messaging. This server only stores user tokens and error logs, and no messages are saved. ", @@ -47,7 +46,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2024-02-28 00:37:18.398000", + "modified": "2024-02-28 11:03:30.518196", "modified_by": "Administrator", "module": "Integrations", "name": "Push Notification Settings", diff --git a/frappe/integrations/workspace/integrations/integrations.json b/frappe/integrations/workspace/integrations/integrations.json index 73a1a393a5..3fe9965bcc 100644 --- a/frappe/integrations/workspace/integrations/integrations.json +++ b/frappe/integrations/workspace/integrations/integrations.json @@ -1,6 +1,6 @@ { "charts": [], - "content": "[{\"type\":\"header\",\"data\":{\"text\":\"Reports & Masters\",\"col\":12}},{\"type\":\"card\",\"data\":{\"card_name\":\"Backup\",\"col\":4}},{\"type\":\"card\",\"data\":{\"card_name\":\"Google Services\",\"col\":4}},{\"type\":\"card\",\"data\":{\"card_name\":\"Authentication\",\"col\":4}},{\"type\":\"card\",\"data\":{\"card_name\":\"Settings\",\"col\":4}}]", + "content": "[{\"id\":\"NPK_AfSLQ2\",\"type\":\"header\",\"data\":{\"text\":\"Reports & Masters\",\"col\":12}},{\"id\":\"lDOo58F7ZI\",\"type\":\"card\",\"data\":{\"card_name\":\"Backup\",\"col\":4}},{\"id\":\"ij1pcK8jst\",\"type\":\"card\",\"data\":{\"card_name\":\"Google Services\",\"col\":4}},{\"id\":\"aTlMujEHpN\",\"type\":\"card\",\"data\":{\"card_name\":\"Authentication\",\"col\":4}},{\"id\":\"gY5NXKtXss\",\"type\":\"card\",\"data\":{\"card_name\":\"Settings\",\"col\":4}},{\"id\":\"n_CI3GGqW-\",\"type\":\"card\",\"data\":{\"card_name\":\"Push Notifications\",\"col\":4}}]", "creation": "2020-03-02 15:16:18.714190", "custom_blocks": [], "docstatus": 0, @@ -197,9 +197,28 @@ "link_type": "DocType", "onboard": 0, "type": "Link" + }, + { + "hidden": 0, + "is_query_report": 0, + "label": "Push Notifications", + "link_count": 1, + "link_type": "DocType", + "onboard": 0, + "type": "Card Break" + }, + { + "hidden": 0, + "is_query_report": 0, + "label": "Push Notification Settings", + "link_count": 0, + "link_to": "Push Notification Settings", + "link_type": "DocType", + "onboard": 0, + "type": "Link" } ], - "modified": "2023-05-24 14:58:55.910408", + "modified": "2024-02-28 10:47:38.188832", "modified_by": "Administrator", "module": "Integrations", "name": "Integrations", diff --git a/frappe/push_notification.py b/frappe/push_notification.py index 7045e6321e..861b49dfa0 100644 --- a/frappe/push_notification.py +++ b/frappe/push_notification.py @@ -168,6 +168,7 @@ class PushNotification: raise Exception("Body should be at max 1000 characters") if strip_html: body = frappe.utils.strip_html(body) + response_data = self._send_post_request( "notification_relay.api.send_notification.topic", {"topic_name": topic_name, "title": title, "body": body, "data": json.dumps(data)}, @@ -282,12 +283,12 @@ def auth_webhook(): # Subscribe and Unsubscribe API @frappe.whitelist(methods=["GET"]) -def subscribe(fcm_token: str, project_name: str): +def subscribe(fcm_token: str, project_name: str) -> dict: success, message = PushNotification(project_name).add_token(frappe.session.user, fcm_token) return {"success": success, "message": message} @frappe.whitelist(methods=["GET"]) -def unsubscribe(fcm_token: str, project_name: str): +def unsubscribe(fcm_token: str, project_name: str) -> dict: success, message = PushNotification(project_name).remove_token(frappe.session.user, fcm_token) return {"success": success, "message": message}