Commit Graph

20283 Commits

Author SHA1 Message Date
Alex Vandiver
3325c21e7f tests: Add clarifying comment about "wrong" charset. 2025-08-06 09:41:44 -07:00
Alex Vandiver
218bbe041e upload: Adjust minimum encoding confidence thresholds.
UTF-8 is far and wide the dominant encoding, so we assume that
encoding if we have more than 66% confidence -- this allows it to be
guessed even for short files.  ISO-8859-1 caps at 73% confidence, so
we assume that if it's the best option and it hits that max.
Otherwise, we still require 90% confidence.
2025-08-06 09:41:44 -07:00
Prakhar Pratyush
787d73f018 push_notification: Update the payload data that gets encrypted.
This commit updates the data that gets encrypted to be
the same on both android and iOS.

The data and its format is almost the same as what we send
as FCM payload to android clients with no E2EE support,
changes are:

For send push notification payload:
* 'realm_id`, 'server', 'sender_email', and 'realm_uri' fields
  don't exist in the new payload.
* 'event' field renamed to 'type'
* 'stream' and 'stream_id' fields renamed to 'channel_name'
  and 'channel_id' respectively.
* The value of 'recipient_type' will be 'channel' & 'direct'
  instead of 'stream' & 'private' respectively.
* 'zulip_message_id' field renamed to 'message_id'

For remove push notification payload:
* 'realm_id`, 'server', and 'realm_uri' fields don't exist
  in the new payload.
* 'event' field renamed to 'type'
* 'zulip_message_ids' field renamed to 'message_ids' and it's
  value will be a JSON array instead of a string.

In the existing iOS client, we have no code of our own involved
in constructing the notifications in the UI, and instead we
leave it to the iOS SDK to do so.

Since, for clients with E2EE support the data is going to be
interpreted by our own code, not by the iOS SDK - we are free
to keep the same data and format.

Co-authored-by: Tim Abbott <tabbott@zulip.com>
2025-08-05 16:54:22 -07:00
Prakhar Pratyush
dd134ef325 push_notification: Remove 'content_truncated' field from FCM payload.
This commit removes the 'content_truncated' field from the FCM
payload to send push notification as it was unused by clients.
2025-08-05 16:54:22 -07:00
Prakhar Pratyush
c9edb9c9ce push_notification: Remove 'zulip_message_id' from FCM payload.
This commit removes the 'zulip_message_id' field from the FCM
payload for remove push notification.

Clients that use `zulip_message_ids` instead have been out for
years and we no longer support older client versions that don't.
2025-08-05 16:54:22 -07:00
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
Vector73
f689dfc3c3 message_move: Mark notification messages as read for acting user.
When moving messages, the notification messages should be
automatically marked as read for the user who moved the messages.
2025-08-05 15:27:08 -07:00
Vector73
9eda1f11ca tests: Use built-in users instead of creating new users in tests. 2025-08-05 14:46:12 -07:00
Anders Kaseorg
88b9a2cfbd push_notifications: Guard reference to RemotePushDevice.
This doesn’t exist when ZILENCER_ENABLED is False.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-08-05 11:03:18 -07:00
bedo
121265b188 user_groups: Change return type "NamedUserGroup" to "UserGroup".
A minor type hint bug:
function "get_root_id_annotated_recursive_subgroups_for_groups"
returns UserGroup not NamedUserGroup.
2025-08-04 18:47:09 -07:00
Vector73
0ac24bd437 api: Add support for passing partial to include_subscribers parameter.
Fixes #35318.
2025-08-04 18:43:14 -07:00
Mateusz Mandera
40b1f6eb4e confirmation: Replace RealmCreationKey - use Confirmation instead.
Fixes #20028.

There's no reason to have a special `RealmCreationKey` class - the
`Confirmation` system already does this job.

This is somewhat complicated by the need to write a migration for
`RealmCreationKey`->`Confirmation` for pre-existing, valid objects, to
avoid breaking realm creation links that haven't been used yet.
2025-08-04 18:41:15 -07:00
Mateusz Mandera
072f234269 confirmation: Rename REALM_CREATION to NEW_REALM_USER_REGISTRATION.
Clears up some naming confusion - `REALM_CREATION_LINK_VALIDITY_DAYS` is
a setting which describes the validaty period of RealmCreationKey, not
of Confirmation with REALM_CREATION type. Now that the latter is called
NEW_REALM_USER_REGISTRATION, there should be no confusion about this.
2025-08-04 18:41:00 -07:00
Sahil Batra
072516c2bb channel-folders: Update unique name constraint.
This commit updates code to require unique names for only
non-archived folders in a realm, which means a folder can
use a name which is being used by an archived folder.
2025-08-04 13:22:11 -07:00
Prakhar Pratyush
55cceeaca1 test_push_notifications: Use assertCountEqual for unordered token list.
The order of token values returned by the database query isn't
guaranteed, so 'assertEqual' fails in a flaky way.

This commit uses 'assertCountEqual' to fix that.
2025-08-04 11:33:53 -07:00
Lauryn Menard
7a9b78f1f5 settings: Add user setting to ignore channel folders in left sidebar.
Fixes #35573.
2025-08-01 09:18:19 -07:00
Prakhar Pratyush
6c625a0177 push_notification: Remove "time" field from APNs payload.
This reverts 1862c3d9ab.

The "time" field was added in the APNs payload to log
"Remote queuing latency".

The client doesn't use this field. Ideally, we should have
removed the field from the payload before sending it to APNs.

We no longer log "Remote queuing latency", so it's safe to
remove it from the APNs payload.

Only FCM payload will have this field as it is used by android
clients.
2025-07-30 17:24:57 -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
298a39e457 push_notification: Remove 'modernize_apns_payload'.
The function was used to reformat apns payload sent
by servers older than 613d093d7.

Since we no longer need to worry about servers older
than 1.6.0, it's safe to remove that function.
2025-07-30 17:24:57 -07:00
Alex Vandiver
2491dc47e8 i18n: Swap three docs for ellipsis. 2025-07-30 13:45:53 +00:00
Alex Vandiver
085d137871 upload: Rename attachment_vips_source, as it's not just for vips_source. 2025-07-29 10:01:40 -07:00
Alex Vandiver
e37ee13577 upload: Add charset even on content-types guessed at download time. 2025-07-29 10:01:40 -07:00
Alex Vandiver
0c6b3373be upload: Ensure that we always have a content-type.
Old uploads are stored without a content-type, and guess_type may not
provide a type for them.
2025-07-29 10:01:40 -07:00
Alya Abbott
1bc7696c24 updates: Add Zulip update (level=20). 2025-07-28 23:52:56 -07:00
Alya Abbott
641a436b44 preferences: Update inactive channels preference setting for new UI.
"Hide" is a better verb with the channel folders UI.

Also automatically hide inactive channels at 20+ susbscribed channels,
as we have more content in the left sidebar now.
2025-07-28 23:52:55 -07:00
Sahil Batra
8ae9cca3c9 channel_folders: Check max length restrictions while updating.
This commit updates code to make sure we check maximum allowed
length for name and description for channel folders when updating
them.
2025-07-28 23:12:58 -07:00
Sahil Batra
6186df4f72 channel_folders: Update MAX_NAME_LENGTH to 60. 2025-07-28 23:12:58 -07:00
Sahil Batra
db00ceaeb2 register: Pass channel folder max name and description length.
This commit adds "max_channel_folder_name" and
"max_channel_folder_description" fields to response.

Also updated webapp to use these fields instead of hardcoding
the values.
2025-07-28 23:12:58 -07:00
Sahil Batra
945e5553e4 test_channel_folders: Add test for long name and description.
This commit add tests for name and description being too long
when creating channel folders.
2025-07-28 23:12:58 -07:00
Anders Kaseorg
b404ca1a02 makemessages: Remove vestigial custom JavaScript extraction.
Commit d8a36d0702 (#18075) should have
removed this.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-07-28 17:44:23 -07:00
Prakhar Pratyush
d972bb1ca9 push_notifications: Redact content for older clients if E2EE required.
This commit replaces the `PUSH_NOTIFICATION_REDACT_CONTENT` server
setting with `require_e2ee_push_notifications` realm setting.

If `require_e2ee_push_notifications` set to True:
* Older clients: Content redacted
* Updated clients: Encrypted content

If `require_e2ee_push_notifications` set to False:
* Older clients: Content NOT redacted
* Updated clients: Encrypted content

Note: Older clients refers to clients that don't support E2EE.

Fixes part of #35370.
2025-07-28 17:06:59 -07:00
Prakhar Pratyush
fc6cd9a966 settings: Add require_e2ee_push_notifications realm setting.
This commit adds a realm setting:
"Require end-to-end encryption for push notification content".

This commit just involves backend & UI changes to add the setting,
the impact of this setting is in the next commit.

Fixes part of #35370.
2025-07-28 17:06:59 -07:00
Rohan Gudimetla
cb01bdf0c4 topics: Follow topics that are merged into even after merge.
Previously, when there were two topics -- A and B, and a user
follows topic A, then when messages of topic B are merged into
topic A then topic A loses its follow status.

This is fixed by updating the algorithm for getting the visibility
policy after merge to be followed in the above case.

Fixes #35226
2025-07-28 12:35:30 -07:00
Rohan Gudimetla
8330e7c283 topics: Refactor method that decides topic visibility after merge.
This commit refactors the method
which determines the visibility of two topics merged.

This is a preparatory commit for #35226.
2025-07-28 12:35:30 -07:00
Aman Agrawal
f4dd3aa066 auth: Pass None as default_subdomain to verify the host.
We were not verifying correctly if the host is in the same
subdomain as we never returned None for get_subdomain_from_hostname.
2025-07-28 10:59:38 -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
Lauryn Menard
7cbc321704 help: Remove "Reading direct messages" article.
In #27186, we updated the help center documentation on
reading conversations and removed the article from the
left sidebar.

Removes remaining links to the article in "Printing
messages" and adds a redirect to go to the main article
on "Direct messages".
2025-07-28 09:50:14 -07:00
Prakhar Pratyush
36a2093585 push_notification: Remove dev guard from send E2EE notif codepath.
This commit removes the DEVELOPMENT guard from the new
'send_push_notifications' function in 'handle_push_notification'
and 'handle_remove_push_notification'.
2025-07-27 20:47:16 -07:00
Alex Vandiver
74675fae94 settings: Use get_secret for altcha_hmac.
When building tarballs, we do not have development secrets.
2025-07-25 22:29:51 -07:00
Alex Vandiver
8af90294d8 altcha: More error-proofing around settings validation. 2025-07-25 22:29:51 -07:00
Prakhar Pratyush
6ab6df96c8 push_notification: Send a list of push requests.
Earlier, we were passing a map `device_id_to_encrypted_data`
and http headers as separate fields to bouncer.

The downside of that approach is it restricts the bouncer to
process only one type of notice i.e. either notification for
a new message or removal of sent notification, because it
used to receive a fixed priority and push_type for all the
entries in the map.

Also, using map restricts the bouncer to receive only one
request per device_id. Server can't send multiple notices
to a device in a single call to bouncer.

Currently, the server isn't modelled in a way to make a
single call to the bouncer with:
* Both send-notification & remove-notification request data.
* Multiple send-notification request data to the same device.

This commit replaces the old protocol of sending data with
a list of objects where each object has the required data
for bouncer to send it to FCM or APNs.

This makes things a lot flexible and opens possibility for
server to batch requests in a different way if we'd like to.
2025-07-25 12:47:55 -07:00
Prakhar Pratyush
3d3f4d5e62 push_notification: Remove 'get_apns_payload_data_to_encrypt'.
'get_apns_payload_data_to_encrypt' was added in commit
0ae34ddb65, in parallel
to 'get_message_payload_apns' - to use in E2EE codepath.

The intent was to avoid nesting in the payload returned
by 'get_message_payload_apns' function, just like FCM
payload returned by 'get_message_payload_gcm'.

Turned out, the nesting is helpful in APNs case for various
reasons. So, this commit reverts that function and we'll
continue to use the older structure returned by the function
'get_message_payload_apns'.
2025-07-25 12:47:55 -07:00
Lauryn Menard
07ff9ec4f9 help: Add mobile tab for "Rename a topic" instructions. 2025-07-25 10:09:56 -07:00
Alex Vandiver
25fbb05fea upload: Attempt to guess character set text/* which are served inline.
This is only `text/plain`, currently.  In such cases where the
client-provided content-type also does not specify a `charset`, we use
`chardet` to make a guess, and store that guess to provide later when
serving the content.  The detection is done in a streaming fashion,
and thus should not require re-downloading the full content.
2025-07-24 22:40:12 -07:00
Alex Vandiver
ae001dfa96 upload: Allow uploads to set charset.
Previously, the `user_file.content_type` only contained the MIME type
of the uploaded file; no other parameters were included, meaning that
a file a client specified as `content-type: text/plain; charset=big5`
would be stored with an `Attachment.content_type` of `text/plain`.

Re-construct the full content-type header from `content_type_extra`,
which includes those parameters.

We do not include a test because Django does not support specifying
such parameters in the upload path.
2025-07-24 22:40:12 -07:00
Alex Vandiver
edb5943d8b upload: Use content_type instead of mimetype for consistency. 2025-07-24 22:40:12 -07:00
Alex Vandiver
183da665ac upload: Rename .source to .vips_source. 2025-07-24 22:40:12 -07:00
Anders Kaseorg
fa23059f17 event_schema: Fix Enum validation in check_realm_update and friends.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-07-24 22:35:05 -07:00
Anders Kaseorg
ba53ec5712 event_types: Add missing default EventPushDevice.error_code = None.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-07-24 22:34:20 -07:00