Skip to content

Commit

Permalink
Update deprecated firebase function (#2231)
Browse files Browse the repository at this point in the history
* Update deprecated firebase function

* Mock right function
  • Loading branch information
moisses89 authored Sep 27, 2024
1 parent fc8e7e6 commit a5c3cac
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ def send_message(
data=data,
tokens=tokens,
)
batch_response: BatchResponse = messaging.send_multicast(message, app=self.app)
batch_response: BatchResponse = messaging.send_each_for_multicast(
message, app=self.app
)
responses: List[SendResponse] = batch_response.responses
# Check if there are invalid tokens
invalid_tokens = [
Expand Down
2 changes: 2 additions & 0 deletions safe_transaction_service/notifications/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ def send_notification_task(
success_count, failure_count, invalid_tokens = firebase_client.send_message(
tokens, payload
)
if failure_count:
logger.error("Push notification failed for %i devices", failure_count)
if invalid_tokens:
logger.info(
"Removing invalid tokens for safe=%s. Tokens=%s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_firebase_client(self, initialize_app_mock):
]
batch_response = BatchResponse(responses)
with mock.patch(
"firebase_admin.messaging.send_multicast",
"firebase_admin.messaging.send_each_for_multicast",
return_value=batch_response,
):
(
Expand Down
Empty file added scripts/firebase_test.py
Empty file.

0 comments on commit a5c3cac

Please sign in to comment.