From 2e79f6acb43abe41710e005b49e0528eb586c54e Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Wed, 28 Feb 2024 01:09:46 +0530 Subject: [PATCH] feat: add descriptions to Push Notification Settings - mark it as beta - validate relay server url key --- .../push_notification_settings.json | 19 +++++++++++++++---- .../push_notification_settings.py | 13 +++++++++++-- 2 files changed, 26 insertions(+), 6 deletions(-) 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 f47c20a023..2446ba760f 100644 --- a/frappe/integrations/doctype/push_notification_settings/push_notification_settings.json +++ b/frappe/integrations/doctype/push_notification_settings/push_notification_settings.json @@ -1,12 +1,14 @@ { "actions": [], "allow_rename": 1, + "beta": 1, "creation": "2024-01-04 11:36:08.013039", "doctype": "DocType", "engine": "InnoDB", "field_order": [ - "authentication_credential_section", + "section_break_qgjr", "enable_push_notification_relay", + "authentication_credential_section", "api_key", "api_secret" ], @@ -18,6 +20,7 @@ "label": "Enable Push Notification Relay" }, { + "description": "API Key and Secret to interact with the relay server. These will be auto-generated when the first push notification is sent from any of the apps installed on this site.", "fieldname": "authentication_credential_section", "fieldtype": "Section Break", "label": "Authentication" @@ -25,18 +28,26 @@ { "fieldname": "api_key", "fieldtype": "Data", - "label": "API Key" + "label": "API Key", + "read_only": 1 }, { "fieldname": "api_secret", "fieldtype": "Password", - "label": "API Secret" + "label": "API Secret", + "read_only": 1 + }, + { + "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. ", + "fieldname": "section_break_qgjr", + "fieldtype": "Section Break", + "label": "Relay Settings" } ], "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2024-01-04 17:52:41.383109", + "modified": "2024-02-28 00:37:18.398000", "modified_by": "Administrator", "module": "Integrations", "name": "Push Notification Settings", diff --git a/frappe/integrations/doctype/push_notification_settings/push_notification_settings.py b/frappe/integrations/doctype/push_notification_settings/push_notification_settings.py index b6b081f8e9..83a8cb0a83 100644 --- a/frappe/integrations/doctype/push_notification_settings/push_notification_settings.py +++ b/frappe/integrations/doctype/push_notification_settings/push_notification_settings.py @@ -1,7 +1,8 @@ # Copyright (c) 2024, Frappe Technologies and contributors # For license information, please see license.txt -# import frappe +import frappe +from frappe import _ from frappe.model.document import Document @@ -19,4 +20,12 @@ class PushNotificationSettings(Document): enable_push_notification_relay: DF.Check # end: auto-generated types - pass + def validate(self): + self.validate_relay_server_setup() + + def validate_relay_server_setup(self): + if self.enable_push_notification_relay and not frappe.conf.get("push_relay_server_url"): + frappe.throw( + _("The Push Relay Server URL key (`push_relay_server_url`) is missing in your site config"), + title=_("Relay Server URL missing"), + )