Skip to content

Commit

Permalink
Merge pull request #25126 from tanmoysrt/hotfix-v15-backport-push-not…
Browse files Browse the repository at this point in the history
…ification

feat: add frappe push notification client (backport #24114)
  • Loading branch information
akhilnarang committed Feb 28, 2024
2 parents 79e7c57 + 93ecd40 commit 0cf2de6
Show file tree
Hide file tree
Showing 7 changed files with 433 additions and 3 deletions.
Empty file.
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) {

// },
// });
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": []
}
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"),
)
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
25 changes: 22 additions & 3 deletions frappe/integrations/workspace/integrations/integrations.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"charts": [],
"content": "[{\"type\":\"header\",\"data\":{\"text\":\"<span class=\\\"h4\\\"><b>Reports &amp; Masters</b></span>\",\"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\":\"<span class=\\\"h4\\\"><b>Reports &amp; Masters</b></span>\",\"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,
Expand Down Expand Up @@ -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",
Expand Down
Loading

0 comments on commit 0cf2de6

Please sign in to comment.