push_notifications: Use SentPushNotificationResult dataclass.

Refactoring, no functional change.

This commit refactors `send_e2ee_push_notification_apple`
and `send_e2ee_push_notification_android` to return a
`SentPushNotificationResult` dataclass.

It's a cleaner protocol than passing a mutable data structure
`delete_device_ids` as argument and updating it within
functions.

Fixes part of #35368.
This commit is contained in:
Prakhar Pratyush
2025-08-21 13:25:14 +05:30
committed by Tim Abbott
parent 3e7e81581c
commit 3548764e21
2 changed files with 45 additions and 15 deletions

View File

@@ -28,6 +28,7 @@ from zerver.lib.timestamp import datetime_to_timestamp
from zerver.models import PushDevice, UserMessage
from zerver.models.realms import get_realm
from zerver.models.scheduled_jobs import NotificationTriggers
from zilencer.lib.push_notifications import SentPushNotificationResult
from zilencer.models import RemoteRealm, RemoteRealmCount
@@ -260,7 +261,11 @@ class SendPushNotificationTest(E2EEPushNotificationTestCase):
with (
self.mock_fcm() as mock_fcm_messaging,
mock.patch(
"zilencer.lib.push_notifications.send_e2ee_push_notification_apple", return_value=1
"zilencer.lib.push_notifications.send_e2ee_push_notification_apple",
return_value=SentPushNotificationResult(
successfully_sent_count=1,
delete_device_ids=[],
),
),
self.assertLogs("zerver.lib.push_notifications", level="INFO") as zerver_logger,
self.assertLogs("zilencer.lib.push_notifications", level="WARNING") as zilencer_logger,