Commit Graph

10 Commits

Author SHA1 Message Date
Prakhar Pratyush
1a5cab130d push_notification: Remove obsolete fields from APNs payload.
Mobile push notification payloads for APNs no longer contain
the `server` and `realm_id` fields, which were unused.
2025-08-05 16:54:22 -07:00
Prakhar Pratyush
2225142554 push_notification: Remove "Remote queue latency" log on bouncer.
We haven't ever inspected those logs, since adding the metric.
2025-07-30 17:24:57 -07:00
Prakhar Pratyush
5616be4afa test_e2ee_push_notification: Improve tests to cover more cases.
This commit adds a test and updates a few existing tests to
cover more cases related to send push notifications.

* We no longer mock the 'send_push_notifications_legacy' function
  while testing 'send_push_notifications' codepath and vice-versa.
  This makes the tests more realistic as both functions gets called
  in 'handle_push_notification'.

  This covers the case when only old clients (which don't support
  E2EE) exists for a user. Or only updated clients (which supports
  E2EE) exist.

* Adds a test 'test_both_old_and_new_client_coexists' for the case
  when a user has both type of clients at an instant i.e. they have
  updated a few devices only.
2025-07-28 10:39:48 -07:00
Prakhar Pratyush
d91a6be3f1 push_notification: Return early if no device registered - w/o bouncer.
In 'send_push_notifications_legacy', when a user has no registered
devices:
* `uses_notification_bouncer()`=True: we log "Skipping..." and return.

* `uses_notification_bouncer()`=False: we make some function calls,
  which effectively does nothing.

It's better to have a common check (and log) early in the codepath.
This commit makes that change.
2025-07-28 10:39:48 -07:00
Prakhar Pratyush
7e1afa0e8a push_notification: Send end-to-end encrypted push notifications.
This commit adds support to send encrypted push notifications
to devices registered to receive encrypted notifications.

URL: `POST /api/v1/remotes/push/e2ee/notify`
payload: `realm_uuid` and `device_id_to_encrypted_data`

The POST request needs to be authenticated with the server’s
API key.

Note: For Zulip Cloud, a background fact about the push bouncer is
that it runs on the same server and database as the main application;
it’s not a separate service. So, as an optimization we directly call
'send_e2ee_push_notifications' function and skip the HTTP request.
2025-07-22 17:08:55 -07:00
Alex Vandiver
7da05b3f7d tests: Rename gcm_devices to fcm_devices.
We only use GCM in the code when strictly necessary.
2025-07-16 16:59:58 -07:00
Alex Vandiver
5d585eff37 tests: Remove unnecessary tuples. 2025-07-16 16:59:58 -07:00
Alex Vandiver
3e5af466e4 push_notifications: Remove vestiges of base64 storage of tokens.
APNs tokens are provided by the client in hex, and we store them in
hex.  The existing code which attempts to "validate" them by parsing
them as base64 only works because base64 is a superset of hex.

Enforce that APNs tokens are hex, and remove all of the pieces of test
code which were incorrectly passing them in as base64 strings.
2025-07-16 16:59:58 -07:00
Anders Kaseorg
750a08ad17 ruff: Fix LOG014 exc_info= outside exception handlers.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-06-25 11:49:02 -07:00
Prakhar Pratyush
bf95e9bcae test_push_notifications: Split HandlePushNotificationTest to a new file.
This commit moves `HandlePushNotificationTest` to a new
`test_handle_push_notification.py` file.

It helps in making it easier to work with `test_push_notifications.py`
which was 4000+ lines of code.
2025-04-17 10:55:05 -07:00