-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25126 from tanmoysrt/hotfix-v15-backport-push-not…
…ification feat: add frappe push notification client (backport #24114)
- Loading branch information
Showing
7 changed files
with
433 additions
and
3 deletions.
There are no files selected for viewing
Empty file.
8 changes: 8 additions & 0 deletions
8
frappe/integrations/doctype/push_notification_settings/push_notification_settings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Copyright (c) 2024, Frappe Technologies and contributors | ||
// For license information, please see license.txt | ||
|
||
// frappe.ui.form.on("Push Notification Settings", { | ||
// refresh(frm) { | ||
|
||
// }, | ||
// }); |
69 changes: 69 additions & 0 deletions
69
frappe/integrations/doctype/push_notification_settings/push_notification_settings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"actions": [], | ||
"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": [ | ||
"section_break_qgjr", | ||
"enable_push_notification_relay", | ||
"authentication_credential_section", | ||
"api_key", | ||
"api_secret" | ||
], | ||
"fields": [ | ||
{ | ||
"default": "0", | ||
"fieldname": "enable_push_notification_relay", | ||
"fieldtype": "Check", | ||
"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" | ||
}, | ||
{ | ||
"fieldname": "api_key", | ||
"fieldtype": "Data", | ||
"label": "API Key" | ||
}, | ||
{ | ||
"fieldname": "api_secret", | ||
"fieldtype": "Password", | ||
"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. ", | ||
"fieldname": "section_break_qgjr", | ||
"fieldtype": "Section Break", | ||
"label": "Relay Settings" | ||
} | ||
], | ||
"index_web_pages_for_search": 1, | ||
"issingle": 1, | ||
"links": [], | ||
"modified": "2024-02-28 11:03:30.518196", | ||
"modified_by": "Administrator", | ||
"module": "Integrations", | ||
"name": "Push Notification Settings", | ||
"owner": "Administrator", | ||
"permissions": [ | ||
{ | ||
"create": 1, | ||
"delete": 1, | ||
"email": 1, | ||
"print": 1, | ||
"read": 1, | ||
"role": "System Manager", | ||
"share": 1, | ||
"write": 1 | ||
} | ||
], | ||
"sort_field": "modified", | ||
"sort_order": "DESC", | ||
"states": [] | ||
} |
31 changes: 31 additions & 0 deletions
31
frappe/integrations/doctype/push_notification_settings/push_notification_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright (c) 2024, Frappe Technologies and contributors | ||
# For license information, please see license.txt | ||
|
||
import frappe | ||
from frappe import _ | ||
from frappe.model.document import Document | ||
|
||
|
||
class PushNotificationSettings(Document): | ||
# begin: auto-generated types | ||
# This code is auto-generated. Do not modify anything in this block. | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from frappe.types import DF | ||
|
||
api_key: DF.Data | None | ||
api_secret: DF.Password | None | ||
enable_push_notification_relay: DF.Check | ||
# end: auto-generated types | ||
|
||
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"), | ||
) |
9 changes: 9 additions & 0 deletions
9
frappe/integrations/doctype/push_notification_settings/test_push_notification_settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2024, Frappe Technologies and Contributors | ||
# See license.txt | ||
|
||
# import frappe | ||
from frappe.tests.utils import FrappeTestCase | ||
|
||
|
||
class TestPushNotificationSettings(FrappeTestCase): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.