Skip to content

Commit 8f24ba1

Browse files
Notifications: Allows to get devices and send test notifications for other users (#842)
### Description Please explain the changes you made here. ### Checklist - [ ] Created tests which fail without the change (if possible) - [ ] All tests passing - [ ] Extended the documentation, if necessary
1 parent 917cbfa commit 8f24ba1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

app/core/notification/endpoints_notification.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ async def send_notification(
256256
status_code=201,
257257
)
258258
async def send_test_notification(
259+
user_id: str | None = None,
259260
user: models_users.CoreUser = Depends(is_user_in(GroupType.admin)),
260261
notification_tool: NotificationTool = Depends(get_notification_tool),
261262
):
@@ -270,7 +271,7 @@ async def send_test_notification(
270271
action_module="test",
271272
)
272273
await notification_tool.send_notification_to_user(
273-
user_id=user.id,
274+
user_id=user_id or user.id,
274275
message=message,
275276
)
276277

@@ -280,6 +281,7 @@ async def send_test_notification(
280281
status_code=204,
281282
)
282283
async def send_test_future_notification(
284+
user_id: str | None = None,
283285
user: models_users.CoreUser = Depends(is_user_in(GroupType.admin)),
284286
notification_tool: NotificationTool = Depends(get_notification_tool),
285287
scheduler: Scheduler = Depends(get_scheduler),
@@ -295,7 +297,7 @@ async def send_test_future_notification(
295297
action_module="test",
296298
)
297299
await notification_tool.send_notification_to_users(
298-
user_ids=[user.id],
300+
user_ids=[user_id or user.id],
299301
message=message,
300302
defer_date=datetime.now(UTC) + timedelta(seconds=10),
301303
scheduler=scheduler,
@@ -361,6 +363,7 @@ async def send_test_future_notification_topic(
361363
response_model=list[schemas_notification.FirebaseDevice],
362364
)
363365
async def get_devices(
366+
user_id: str | None = None,
364367
user: models_users.CoreUser = Depends(is_user_in(GroupType.admin)),
365368
db: AsyncSession = Depends(get_db),
366369
):
@@ -371,6 +374,6 @@ async def get_devices(
371374
**Only admins can use this endpoint**
372375
"""
373376
return await cruds_notification.get_firebase_devices_by_user_id(
374-
user_id=user.id,
377+
user_id=user_id or user.id,
375378
db=db,
376379
)

0 commit comments

Comments
 (0)