Spaces:
Sleeping
Sleeping
Merge pull request #37 from yuvabe-ai-labs/feat/notify
Browse files- src/notifications/fcm.py +11 -3
- src/profile/notify.py +4 -0
src/notifications/fcm.py
CHANGED
|
@@ -36,7 +36,13 @@ def get_access_token():
|
|
| 36 |
return credentials.token
|
| 37 |
|
| 38 |
|
| 39 |
-
async def send_fcm(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
"""Send push notifications using Firebase HTTP v1."""
|
| 41 |
if not tokens:
|
| 42 |
return
|
|
@@ -55,8 +61,10 @@ async def send_fcm(tokens: list[str], title: str, body: str, data: dict | None =
|
|
| 55 |
message = {
|
| 56 |
"message": {
|
| 57 |
"token": token,
|
| 58 |
-
"
|
| 59 |
-
"
|
|
|
|
|
|
|
| 60 |
}
|
| 61 |
}
|
| 62 |
|
|
|
|
| 36 |
return credentials.token
|
| 37 |
|
| 38 |
|
| 39 |
+
async def send_fcm(
|
| 40 |
+
tokens: list[str],
|
| 41 |
+
title: str,
|
| 42 |
+
body: str,
|
| 43 |
+
data: dict | None = None,
|
| 44 |
+
priority: str = "high",
|
| 45 |
+
):
|
| 46 |
"""Send push notifications using Firebase HTTP v1."""
|
| 47 |
if not tokens:
|
| 48 |
return
|
|
|
|
| 61 |
message = {
|
| 62 |
"message": {
|
| 63 |
"token": token,
|
| 64 |
+
"data": {"title": title, "body": body, **(data or {})},
|
| 65 |
+
"android": {
|
| 66 |
+
"priority": priority,
|
| 67 |
+
},
|
| 68 |
}
|
| 69 |
}
|
| 70 |
|
src/profile/notify.py
CHANGED
|
@@ -15,6 +15,7 @@ def ensure_list(value):
|
|
| 15 |
return list(value)
|
| 16 |
return [value]
|
| 17 |
|
|
|
|
| 18 |
# -------------------------------
|
| 19 |
# SEND TO MENTOR + LEAD
|
| 20 |
# -------------------------------
|
|
@@ -41,6 +42,7 @@ async def send_leave_request_notification(session, user, leave, mentor_ids, lead
|
|
| 41 |
"screen": "MentorApproval",
|
| 42 |
"leave_id": str(leave.id),
|
| 43 |
},
|
|
|
|
| 44 |
)
|
| 45 |
|
| 46 |
|
|
@@ -71,6 +73,7 @@ async def send_leave_status_notification(session, leave, mentor_name, lead_ids):
|
|
| 71 |
"screen": "LeaveDetails",
|
| 72 |
"leave_id": str(leave.id),
|
| 73 |
},
|
|
|
|
| 74 |
)
|
| 75 |
|
| 76 |
# 2) Notify all leads
|
|
@@ -83,4 +86,5 @@ async def send_leave_status_notification(session, leave, mentor_name, lead_ids):
|
|
| 83 |
"screen": "LeaveDetails",
|
| 84 |
"leave_id": str(leave.id),
|
| 85 |
},
|
|
|
|
| 86 |
)
|
|
|
|
| 15 |
return list(value)
|
| 16 |
return [value]
|
| 17 |
|
| 18 |
+
|
| 19 |
# -------------------------------
|
| 20 |
# SEND TO MENTOR + LEAD
|
| 21 |
# -------------------------------
|
|
|
|
| 42 |
"screen": "MentorApproval",
|
| 43 |
"leave_id": str(leave.id),
|
| 44 |
},
|
| 45 |
+
priority="high",
|
| 46 |
)
|
| 47 |
|
| 48 |
|
|
|
|
| 73 |
"screen": "LeaveDetails",
|
| 74 |
"leave_id": str(leave.id),
|
| 75 |
},
|
| 76 |
+
priority="high",
|
| 77 |
)
|
| 78 |
|
| 79 |
# 2) Notify all leads
|
|
|
|
| 86 |
"screen": "LeaveDetails",
|
| 87 |
"leave_id": str(leave.id),
|
| 88 |
},
|
| 89 |
+
priority="high",
|
| 90 |
)
|