Commit Graph

20476 Commits

Author SHA1 Message Date
Prakhar Pratyush
29ea8a07c2 push_notification: Add support to configure priority and push_type.
This commit adds support to let server configure:
* fcm_priority
* apns_priority
* apns_push_type

while sending E2EE push notifications.

The values of these fields will vary depending on whether the
send request is to send push notification for a message or
revoke an already sent notification.

Since, the bouncer receives encrypted data so it can't inspect
the payload to determine whether it is a removal request or not,
hence can't configure priority on its own.

The server needs to specify explicitly.

We're not simply sending a single 'is_removal' flag because
allowing the server to configure them separately will help in
future to support other types of notifications with a different
combination of priority and push_type, like whose aim is to notify
user about information other than a new message or removal request.

Fixes part of #35368.
2025-07-24 11:56:42 -07:00
Prakhar Pratyush
945f27f099 push_notification: Remove redundant @activate_push_notification_service.
In 'test_e2ee_push_notifications', the `SendPushNotificationTest` class
is already decorated with `@activate_push_notification_service()`,
so individual test methods do not need to repeat it.
2025-07-24 11:56:42 -07:00
Pratik Chanda
e7629ef07d message_flags: Fix message flags not updating for wildcard mentions.
Earlier, editing a message with wildcard mention and removing the
wildcard mention didn't properly remove the corresponding flag for
it in the message object. It was only updating flags when mentions
were present in new message but not the other way around.

This commit fixes this behaviour by removing flags if the new message
removed mention from it.
2025-07-24 11:52:20 -07:00
Lauryn Menard
95e6af8c64 api-docs: Revise feature level 404 and 392 changes entries.
Updates the changelog entries for feature levels 404 and 392, and
revises the descriptive text for the topics_policy channel and
realm level settings.

The feature level 404 changes were originally added in commit
a77fc6aa79.

The feature level 392 changes were originally added in commit
deaa43c7e6.
2025-07-23 11:49:55 -07:00
Prakhar Pratyush
1c7dd83dbe register_push_device: Add an error code to push-not-configured error.
This commit adds an error code to make it easier for clients
to identify when push device registration is rejected due to
server not being configured to use push notification service.

Fixes part of 35368.
2025-07-23 11:11:46 -07:00
Alex Vandiver
5319a2f33e narrow: Skip topic mutes for DM narrows. 2025-07-22 20:57:36 -07:00
Alex Vandiver
83acf70d0f models: Add a partial index on unread DMs.
This helps the find_first_unread_anchor call for DMs with a user.
2025-07-22 20:57:36 -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
Sahil Batra
eb57fe10a2 streams: Handle empty topic only streams being used for announcements.
This commit updates code to send messages to "general chat" topic
if streams used for announcements for "New user signups",
"New created streams", "Moderation requests" and "Zulip updates"
have topics policy set to allow only "general chat" messages.
2025-07-22 16:59:47 -07:00
Mateusz Mandera
639972b753 get_recursive_group_members: Use DISTINCT in the query.
Having repetitions in the result can cause subtle bugs in callers that
don't expect it.
2025-07-22 16:21:05 -07:00
Alex Vandiver
2f4dd72076 push_notifications: Adjust APNs tokens to be case-insensitive in the database.
APNs apparently treats its tokens case-insensitively; FCM does not.
Adjust the `unique_together` to instead be separate partial
constraints, keyed on the `kind` of the PushDeviceToken.
2025-07-22 14:30:13 -07:00
Evy Kassirer
935a8b9278 events: Consider partial_subscribers key in apply_event.
Fixing bug reported here:
https://chat.zulip.org/#narrow/channel/343-kandra-errors/topic/KeyError.3A.20'subscribers'/near/2226586
2025-07-22 12:49:28 -07:00
Alex Vandiver
dbe1f778cf grafana: Be more forgiving of missing alert keys. 2025-07-22 12:20:04 -07:00
Mateusz Mandera
25a75b9ed7 scim_filter: Remove unnecessary join.
This join is completely redundant. We don't need to join the tables to
add filtering by realm id in the db queries for SCIM user lookup.
2025-07-22 12:02:06 -07:00
Mateusz Mandera
3052d0cca7 scim: Make "id" a string in our responses.
In SCIM, this is always a string, even if numerical. While SCIM clients
seem to handle our prior behavior, this was a bug nonetheless.
2025-07-22 12:02:06 -07:00
Mateusz Mandera
88d1dcaf02 user_groups: Extract check_user_group_can_be_deactivated helper. 2025-07-22 12:02:06 -07:00
Mateusz Mandera
8f66e0b640 access_user_group_api_value_for_setting: Change arg to realm.
This is a cleaner interface, allowing this function to be called in
contexts without a user_profile object.
2025-07-22 12:02:06 -07:00
Mohammad Reza Kianifar
d02cafce52 welcome_bot: Support auto-reply for 1:1 DMs using DM groups.
Welcome Bot should auto-reply to users in 1:1 DMs, including when
the direct message group recipient model is used. This ensures
the bot detects and responds to messages where it is a recipient,
for both PERSONAL and DIRECT_MESSAGE_GROUP recipient types.

Fixes: part of issue #25713.
2025-07-21 22:48:01 -07:00
Mohammad Reza Kianifar
9c036024bd scheduled_messages: Set read_by_sender for self-DMs using DM group.
When using direct message group as the recipient for 1:1 or self DMs,
ensure read_by_sender is set correctly when scheduling a message.
2025-07-21 22:46:38 -07:00
Mateusz Mandera
71f1c5677a import: Add TODO about improving how initial DMs are generated.
For an organization with a very large amount of users, the current
approach of generating all these DMs at import time can be slow.
2025-07-21 11:08:25 -07:00
Mateusz Mandera
2a6c3a7ab8 import: Send channel Welcome Bot messages to imported organizations.
Closes #35280.

When importing from other apps, we want to generate initial channel
messages. We don't have the usual Zulip-style range of channels, so we
just settle on sending all these messages to a single channel, chosen
following the same criteria as already implemented in #35339.
2025-07-21 11:08:25 -07:00
Mateusz Mandera
8378401205 onboarding: Be consistent about channel name realm attr access.
It's messy to sometimes do `realm.ZULIP_..._CHANNEL_NAME` and sometimes
`Realm.ZULIP_..._CHANNEL_NAME`. Let's be consistent and access those as
a class attr `Realm.ZULIP_..._CHANNEL_NAME`.
2025-07-21 11:08:25 -07:00
Mateusz Mandera
df7bb3cdd4 slack: Handle float "ts" in attachment info.
It's rare, but sometimes we see floats in this field.
2025-07-21 09:24:03 -07:00
Alya Abbott
87473a726d updates: Add update message (level=19). 2025-07-18 17:48:53 -07:00
Mateusz Mandera
a9ebadbf9b import: Choose default announcement channel for imports from other apps.
The data conversion logic for exports from other apps will try to set
these announcement channels based on presence of channels with an
appropriate default name - however those sometimes do not exist.

Then it falls on the import process to choose a good default value. That
default should be the channel with the most subscribers.

This requires a tweak to the send_zulip_update_announcements_to_realm
code to respect the "Starting tomorrow, users in your organization will
receive updated" behavior promised to admins in the initial DMs.

Closes #34984.
2025-07-18 17:45:21 -07:00
Mateusz Mandera
342c00cc7b data_import: Set a default announcements channel for 3rd party imports.
For Slack, Mattermost and RocketChat, set the default announcement
channels if the sane default channel is available in the import.

The next commit will add a mechanism to choose an alternative default if
the expected channel name is not present.

Addresses the major part of #34984.
2025-07-18 17:45:21 -07:00
ducnb
715d07c231 api: Add administrator endpoint for updating user status.
Fixes #33139.
2025-07-18 17:37:26 -07:00
Alex Vandiver
4c2cf4dca8 compilemessages: Weblate's Language-Team uses <>. 2025-07-18 04:33:52 +00:00
Tim Abbott
d465705177 api: Document meaning for twenty_four_hour_time=null.
This documentation-only change will allow us to add that as a valid
value in the future, by having client implementations not crash on
seeing the value.

See [the API design discussion](https://chat.zulip.org/#narrow/channel/378-api-design/topic/.60user_settings.2Etwenty_four_hour_time.60/near/2220575).
2025-07-17 17:45:49 -07:00
Tim Abbott
fe8853bcc9 api: Increment API feature level to 407. 2025-07-17 15:45:17 -07:00
Vector73
9e63cd57fe tests: Add tests for deleting private messages. 2025-07-17 15:44:53 -07:00
Vector73
a02614204a settings: Add can_set_delete_message_policy_group setting.
Adds new organization setting `can_set_delete_message_policy_group`
for defining who can set per-channel message delete permissions.

Fixes #34214.
2025-07-17 15:44:53 -07:00
Vector73
97a43fa6b6 stream_settings: Add can_delete_own_message_group setting.
Adds per-channel `can_delete_own_message_group` setting for
defining who can delete their own message in the channel.
2025-07-17 15:44:52 -07:00
Vector73
c4e641365b stream_settings: Add can_delete_any_message_group setting.
Adds per-channel can_delete_any_message_group setting for
defining who can delete any message in the channel.
2025-07-17 15:44:42 -07:00
Anders Kaseorg
d24eab02d2 request: Use Django 5.2 HttpRequest.get_preferred_type.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-07-17 14:37:11 -07:00
Anders Kaseorg
6006ba4c44 upload: Make closest_thumbnail_format take an HttpRequest.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-07-17 14:37:11 -07:00
Alex Vandiver
d1995687c9 i18n: Remove mobile.json-related codepaths. 2025-07-16 19:59:20 -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
PieterCK
9de1b47ffa slack_import: Improve topic name for Slack threads.
This updates the topic name format for Slack threads to include a
snippet of the original message. Currently the format looks like this;
"{date} Slack thread {n}", which provides little to no context about the
thread.

Currently we also use the `thread_ts_str` key to keep track of Slack
threads we're converting, this key format makes it so that it has a
small chance of combining threads with the same timestamp under one
topic. This commit updates it to use a new key format, `thread_key`.

Fixes #27661.
2025-07-16 14:32:05 -07:00
Mateusz Mandera
4210ccc5db realm_reactivation: Use redirect-to-POST trick.
Uses the approach done for email change confirmations in #34980 to avoid
triggering a reactivation via just a GET request. Instead, the GET
should return a page which will trigger the browser to then POST the key
to the endpoint.
2025-07-16 13:53:20 -07:00
Tim Abbott
5b00cb6753 Partially revert "home: Enable partial_subscribers in web app."
This reverts commit 458c660f65.

We realized we need one more pull request before we can turn this on.
I kept the hunks related to finalizing the cutoffs.
2025-07-16 13:26:33 -07:00
Tim Abbott
458c660f65 home: Enable partial_subscribers in web app.
Fixed #34244.
2025-07-16 13:11:56 -07:00
Apoorva Pendse
6166576059 api_docs: Link to message-formatting article where relevant.
Fixes: https://chat.zulip.org/#narrow/channel/412-api-documentation/topic/document.20html.20for.20markdown/near/2216238.
Signed-off-by: Apoorva Pendse <apoorvavpendse@gmail.com>
2025-07-16 09:39:41 -07:00
apoorvapendse
ebbb208a47 streams: Extract channel description validation logic.
Fixes: Point 1 of https://github.com/zulip/zulip/pull/33405#issuecomment-3064452310
Signed-off-by: apoorvapendse <apoorvavpendse@gmail.com>
2025-07-16 09:38:36 -07:00
apoorvapendse
947658def4 streams: Extract topics_policy validation.
Fixes: Point 3 of
https://github.com/zulip/zulip/pull/33405#issuecomment-3064452310.
Signed-off-by: apoorvapendse <apoorvavpendse@gmail.com>
2025-07-16 09:38:36 -07:00
akshatdalton
520c58bf6b narrow: Fix topic highlighting issue with apostrophes in search results.
This commit addresses the issue where the topic highlighting
in search results was offset by one character when an
apostrophe was present. The problem stemmed from the disparity
in HTML escaping generated by the function `func.escape_html` which
is used to obtain `topic_matches` differs from the escaping performed
by the function `django.utils.html.escape` for apostrophes (').

func.escape_html | django.utils.html.escape
-----------------+--------------------------
      &#39;      |           &#x27;

To fix this SQL query is changed to return the HTML-escaped
topic name generated by the function `func.escape_html`.

Fixes: #25633.

Co-authored-by: Pieter CK <pieterceka123@gmail.com>
2025-07-16 09:26:40 -07:00
Alex Vandiver
c977730f81 mime_types: Remove incorrect comment, and add audio/mp4 and audio/webm.
The comment came from when the only use of `AUDIO_INLINE_MIME_TYPES`
was based on the result of `mimetypes.guess_type`, which would happen
to always return `video/mp4` and not of `audio/mp4` for `.mp4` files.
Before being merged, the code was updated to examine uploaded files'
content-type, which can very well be `audio/mp4` -- and in such cases,
should very much be shown inline.

Add the missing content-types to `AUDIO_INLINE_MIME_TYPES`, and remove
the comment.
2025-07-16 09:20:31 -07:00
Sahil Batra
70d18d7528 tests: Move test for permission to update topics_policy.
This commit updates tests for permission to update topics_policy
of a channel to test_channel_permissions.py.
2025-07-15 15:54:30 -07:00