chore: remove function description comment where docstring available
This commit is contained in:
parent
51f5f44e31
commit
fc459fb8b6
1 changed files with 8 additions and 11 deletions
|
|
@ -57,7 +57,6 @@ class PushNotification:
|
||||||
data = self._send_post_request("notification_relay.api.topic.add", {"topic_name": topic_name})
|
data = self._send_post_request("notification_relay.api.topic.add", {"topic_name": topic_name})
|
||||||
return data["success"]
|
return data["success"]
|
||||||
|
|
||||||
# Remove Topic
|
|
||||||
def remove_topic(self, topic_name: str) -> bool:
|
def remove_topic(self, topic_name: str) -> bool:
|
||||||
"""
|
"""
|
||||||
Remove a notification topic.
|
Remove a notification topic.
|
||||||
|
|
@ -81,7 +80,6 @@ class PushNotification:
|
||||||
)
|
)
|
||||||
return data["success"]
|
return data["success"]
|
||||||
|
|
||||||
# Unsubscribe Topic (User)
|
|
||||||
def unsubscribe_topic(self, user_id: str, topic_name: str) -> bool:
|
def unsubscribe_topic(self, user_id: str, topic_name: str) -> bool:
|
||||||
"""
|
"""
|
||||||
Unsubscribe a user from a topic.
|
Unsubscribe a user from a topic.
|
||||||
|
|
@ -191,11 +189,11 @@ class PushNotification:
|
||||||
# Generate new credentials
|
# Generate new credentials
|
||||||
token = frappe.generate_hash(length=48)
|
token = frappe.generate_hash(length=48)
|
||||||
# store the token in the redis cache
|
# store the token in the redis cache
|
||||||
frappe.cache().set_value(f"{self._get_site_name}:push_relay_registration_token", token, ex=600)
|
frappe.cache().set_value(f"{self._site_name}:push_relay_registration_token", token, ex=600)
|
||||||
body = {
|
body = {
|
||||||
"endpoint": self._get_site_name,
|
"endpoint": self._site_name,
|
||||||
"protocol": self._get_site_protocol,
|
"protocol": self._site_protocol,
|
||||||
"port": self._get_site_port,
|
"port": self._site_port,
|
||||||
"token": token,
|
"token": token,
|
||||||
"webhook_route": "/api/method/frappe.push_notification.auth_webhook",
|
"webhook_route": "/api/method/frappe.push_notification.auth_webhook",
|
||||||
}
|
}
|
||||||
|
|
@ -230,20 +228,19 @@ class PushNotification:
|
||||||
else:
|
else:
|
||||||
client = FrappeClient(relay_server_endpoint)
|
client = FrappeClient(relay_server_endpoint)
|
||||||
params["project_name"] = PushNotification.project_name
|
params["project_name"] = PushNotification.project_name
|
||||||
params["site_name"] = self._get_site_name
|
params["site_name"] = self._site_name
|
||||||
return client.post_api(method, params)
|
return client.post_api(method, params)
|
||||||
|
|
||||||
# Helper methods to fetch properties
|
|
||||||
@property
|
@property
|
||||||
def _get_site_name(self) -> str:
|
def _site_name(self) -> str:
|
||||||
return urlparse(frappe.utils.get_url()).hostname
|
return urlparse(frappe.utils.get_url()).hostname
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _get_site_protocol(self) -> str:
|
def _site_protocol(self) -> str:
|
||||||
return urlparse(frappe.utils.get_url()).scheme
|
return urlparse(frappe.utils.get_url()).scheme
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _get_site_port(self) -> str:
|
def _site_port(self) -> str:
|
||||||
site_uri = urlparse(frappe.utils.get_url())
|
site_uri = urlparse(frappe.utils.get_url())
|
||||||
if site_uri.port is not None:
|
if site_uri.port is not None:
|
||||||
return str(site_uri.port)
|
return str(site_uri.port)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue