Skip to content

Commit

Permalink
fix: Enqueue request and miscellanous fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marination committed Jan 10, 2024
1 parent 99b8c29 commit 27dcf76
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion landa/firebase_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _get_access_token(self) -> str:
def headers(self):
"""Get headers for authorized requests."""
return {
"Authorization": "Bearer " + self.token,
"Authorization": f"Bearer {self.token}",
"Content-Type": "application/json; UTF-8",
}

Expand Down
15 changes: 12 additions & 3 deletions landa/water_body_management/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import json

import frappe
from frappe import _

Expand Down Expand Up @@ -46,12 +44,23 @@ def create_firebase_notification(doc, event):
return

# Send notification to topic
frappe.enqueue(
send_firebase_notification,
queue="default",
file_path=file_path,
project_id=project_id,
topic=topic,
change_log=change_log,
)


def send_firebase_notification(file_path, project_id, topic, change_log):
try:
fcm = FirebaseNotification(file_path, project_id)
response = fcm.send_to_topic(topic, change_log)
response.raise_for_status()
except Exception:
frappe.log_error(message=frappe.get_traceback(), title="Firebase Notification Error")
frappe.log_error(message=frappe.get_traceback(), title=_("Firebase Notification Error"))


def doc_eligible(doc):
Expand Down

0 comments on commit 27dcf76

Please sign in to comment.