Commit Graph

1015 Commits

Author SHA1 Message Date
Sahil Batra
764f4aa2e0 groups: Use realm_for_sharding for limiting NamedUserGroup queries.
For get and filter queries of NamedUserGroup, realm_for_sharding
field is used instead of realm field, as directly using
realm_for_sharding field on NamedUserGroup makes the query faster
than using realm present on the base UserGroup table.
2025-09-23 12:15:53 -07:00
Alex Vandiver
7480510aeb embeds: Propagate group membership before updating UserMessage flags. 2025-08-13 10:38:40 -07:00
Vector73
f1d1d5f1a4 events: Add support for sending presence events in modern format.
If the client has passed `simplified_presence_events` as true
in the `client_capabilities` parameter of the `POST /register`
request, then the server will send `presence` events with the
`presences` field, which has the user presence data in the
modern API format. When that client capability is false, the
`presence` event will be unchanged and sent with the user
presence data in the legacy format.
2025-08-12 12:37:54 -07:00
Vector73
88761f70a2 event_schema: Rename "presence" event to "legacy_presence". 2025-08-12 12:14:56 -07:00
Sahil Batra
5675860707 channel-folders: Send event when reordering channel folders. 2025-08-12 11:17:17 -07:00
Saubhagya Patel
bb5c87e306 bots: Add a setting to customize the Welcome Bot message.
This commit includes the following changes:
- Add an administrator setting to customize the Welcome Bot
message when sending an invitation.
- Add an API endpoint to test the customized Welcome Bot message
by sending a copy of the message to the administrator.

Fixes #27663.

Co-authored-by: Akarsh Jain <akarsh.jain.790@gmail.com>
2025-08-08 18:59:37 -07:00
Anders Kaseorg
4603472fe3 event_types: Combine typing_edit_message variants.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-07-24 22:33:49 -07:00
Prakhar Pratyush
5f8edf669d zerver: Add endpoint to register a push device to server.
This commit adds an endpoint to register a push device
to receive E2EE push notifications.
2025-07-14 14:52:39 -07:00
Rohan Gudimetla
a3e7ef8e71 left_sidebar: Add navigation option to go to top unread topic.
This commit adds option in personal settings to allow
navigation of channel links in left sidebar to the top
unread topic in that channel.

In cases of no unread messages in unmuted topics of the channel,
it falls back to the top topic of channel.

Fixes #35066
2025-07-03 18:14:10 -07:00
PieterCK
38d2a95aa1 users: Add acting_user to do_update_outgoing_webhook_service.
The `acting_user` parameter is added in preparation to make
`do_update_outgoing_webhook_service` log `RealmAuditLog` when updating
bots service. It doesn't have any use as of right now.
2025-07-01 13:24:58 -07:00
PieterCK
fb229a013e actions: Refactor do_update_outgoing_webhook_service.
This updates `do_update_outgoing_webhook_service` to use
`BotServicesOutgoing` as the schema for the updated service data we send
back to client because it's the schema `bot_data.update` expects.

The function is also refactored to allow updating specific fields of the
Service row instead of requiring all value for the Service fields to be
passed.

This is a prep commit for #34524, it adds another field to the Service
field.
2025-07-01 13:24:35 -07:00
Evy Kassirer
4313648ca5 streams: Add subscriber_count to page load data. 2025-06-19 14:25:41 -07:00
Sahil Batra
b655bd14ea messages: Use "\x07" as topic for DMs and group DMs.
This commit updates code to use "\x07" as value for
"subject" field of Message objects for DMs and group
DMs, so that we have a unique value for DMs and group
DMs which cannot be used for channel messages.

This helps in avoiding having an empty string value as
topic for DMs, which is also used for "general chat"
channel messages, as large number of DMs in the realm
resulted in PostgreSQL query planner thinking that there
are too many "general chat" messages and thus generated
bad query plans for operations like fetching
"general chat" messages in a stream or moving messages
to and from "general chat" topic.

This change as done for ArchivedMessage and
ScheduledMessage objects as well.

Note that the clients still get "subject" value as
an empty string "".

This commit also adds tests for checking that "\x07"
cannot be used as topic for channel messages.

Fixes #34360.
2025-06-19 10:44:37 -07:00
Shubham Padia
00fe2236da message_delete: Sort message_ids when sending delete_message event.
Fixes #34324.
https://chat.zulip.org/#narrow/channel/412-api-documentation/topic/Make.20message_ids.20from.20message.20update.20event.20sorted
2025-06-18 16:48:21 -07:00
Shubham Padia
37bfb7c963 message_edit: Sort message_ids when sending update_message event.
https://chat.zulip.org/#narrow/channel/412-api-documentation/topic/Make.20message_ids.20from.20message.20update.20event.20sorted
2025-06-18 16:48:21 -07:00
Vector73
6094bbe8a5 stream_settings: Add new topics_policy setting.
Added `topics_policy` channel setting to configure sending
messages in the empty topic.

Fixes #33549.
2025-06-17 17:05:58 -07:00
Vector73
62c67eae8e settings: Add a new topics_policy realm setting.
Added a new realm setting, `topics_policy` and deprecated
`mandatory_topics` setting as it now replaced by `topics_policy`.

Fixes part of #33549.
2025-06-17 17:05:58 -07:00
Sahil Batra
88b47be938 channel_folders: Pass realm as argument to check_add_channel_folder.
Passing realm explicitly to check_add_channel_folder instead of
using realm field from acting_user seems much cleaner and readable.
2025-05-29 15:39:03 -07:00
Aditya Kumar Kasaudhan
c5f126c6ff navigation_views: Add backend for navigation views in left sidebar.
Fixes part of #32077.
2025-05-23 16:25:08 -07:00
Sahil Batra
2f34e6d24c streams: Add API support to update folder of a stream.
Fixes part of #31972.
2025-05-20 13:25:06 -07:00
Sahil Batra
5de0f265bd channel_folders: Add support to update channel folders.
Fixes part of #31972.
2025-05-20 13:25:06 -07:00
Sahil Batra
332abd9e91 channel_folder: Add API to create a channel folder.
This commit also includes code to include channel_folders
data in register response.

Fixes part of #31972.
2025-05-20 13:25:06 -07:00
Saubhagya Patel
70e45f45c0 settings: Add setting for marking resolved-topic notices as read.
This commit adds a new personal setting
`resolved_topic_notice_auto_read_policy` which controls how
resolved-topic notices are marked as read for a user.

Fixes #33599.
2025-05-13 16:23:21 -07:00
Aman Agrawal
cc4b4f5670 users: Add new option in web_channel_default_view.
Added "list of topics" option which will allow users to indicate
that they want to view an inbox style list of topics on visiting
a channel link.
2025-05-09 15:13:56 -07:00
bedo
c0a9ca8e9a tests: Pass update_fields to all stream.save().
A prep PR to 34308.

Explicitly pass the fields to be updated,
This increases performance but most importantly
prevents overwriting the db-saved value of
"subscriber_count" field (added in an upcoming PR)
with the in-memory default value of 0,
since "subscriber_count" will only be updted
via the db.

Migrate some tests to use do_ functions instead of
direclty modifying the state.
2025-04-15 10:28:18 -07:00
Shubham Padia
1014de23a8 streams: Send different peer events for web & non-web public streams.
Earlier, we used to send a single event for all web-public and public
streams. But public streams can have guests, which means the peer user
ids for each of them can be different based on which guests are
subscribed to which channel.
In the previous code, we were using the last stream id from another loop
to get subscribers, which was causing a lot of non-deterministic
failures in our test, since that stream id could keep on changing.
Moreover, it doesn't make much sense to use that id here.
This commit still keeps around the optimisation for public channels with
non-guest users. It will send one event for all public channels with
non-guest users, one for web public channels and for the rest of the
channels it will send an event for each channel with a different set of
peer user ids.
2025-04-10 15:08:48 -07:00
Sahil Batra
7c470f0161 streams: Fix events send when archiving and unarchiving streams. 2025-04-08 12:41:09 -07:00
Shubham Padia
8ee80f29ae test_events: Explicitly subscribe both users to a stream when testing.
When testing `do_deactivate_user`, we were getting a non-deterministic
failure where `peer_remove` event was not being sent. We were unable to
figure out the exact reason why, but this commit subscribes both the
user being deactivated and the user receiving the event to a new channel
in the hopes of this event being always sent regardless of other test
conditions.
2025-04-07 10:18:52 -07:00
Shubham Padia
53983c9eb9 users: Send peer_remove on deactivating user.
Tweaked by tabbott to clean up the API changelog.

Fixes #34245.
2025-04-03 18:07:31 -07:00
Sahil Batra
8528453db6 user_groups: Add do_reactivate_user_group function.
This commit adds do_reactivate_user_group which will be used
to reactivate user groups.

Fixes part of #23568.
2025-04-03 13:00:17 -07:00
Shubham Padia
6833ad8a21 user_groups: Send metadata access related events on remove subgroups.
Fixes #33420.
2025-03-25 13:20:06 -07:00
Shubham Padia
c06dae81fb user_groups: Send metadata access related events on add subgroups. 2025-03-25 13:20:06 -07:00
Shubham Padia
e089eb0fa1 user_groups: Send metadata access related events on remove members. 2025-03-25 13:20:06 -07:00
Shubham Padia
8c069674b0 user_groups: Send metadata access related events on add members. 2025-03-25 13:20:06 -07:00
Shubham Padia
b3862c5008 user_groups: Use UserGroupMembersDict in initial state data.
On the event side, orjson does the work of converting
UserGroupMembersData to json. But when fetching intial state data,
UserGroupMembersData was being returned which is not
json-serializable. This was causing a mismatch in the `verify_action`
workflow of test_events related to stream group settings where
apply_events resulted in a state with `direct_members` and
`direct_subgroups` as part of an ordinary dict, while fetching initial
state data was giving us a UserGroupMembersData class.
This commit uses UserGroupMembersDict where appropriate. It will
still be good to keep around the dataclass class since it has the added
benefit of storing the relevant value when needed.
2025-03-18 11:53:48 -07:00
Shubham Padia
25f91a51ec streams: Do not send update event to users gaining metadata access. 2025-03-18 11:14:39 -07:00
Shubham Padia
0c7c13fc30 streams: Set include_all to True.
We set it to True when fetching streams in `fetch_initial_state_data`
and when trying to find newly accessible or inaccesible streams on role
update. We've added tests for role update, but since we don't test
`fetch_initial_state_data` directly, the role update tests changed in
this commit will fail if include_all is not set to True in
`fetch_inital_state_data`.
2025-03-18 11:14:39 -07:00
Shubham Padia
ec34f0b80f test_events: Use do_test_change_role to simplify role change tests.
All those if conditions and different number of events for each
condition was making the current test function unreadable. This commit
hopes to simplify that. All the setup work for the tests is still done
in the respective test functions and not `do_test_change_role`.
2025-03-18 11:14:39 -07:00
Tim Abbott
e18a87ce6c lint: Fix ruff-format violations.
Apparently these were masked by commits after
ac9b7b5fa1 in the PR fixing them.
2025-03-17 14:28:02 -07:00
Shubham Padia
ac9b7b5fa1 user_groups: Rename UserGroupMembersDict to UserGroupMembersData.
UserGroupMembersData is not serializable by orjson. We will be
introducing a TypedDict (which is serializable) in the next commit
called UserGroupMembersDict. This rename will help us distinguish
between the two.
2025-03-17 14:21:37 -07:00
Prakhar Pratyush
c70a3ffb0a populate_db: Mark onboarding steps as seen for existing users.
This commit updates populate_db to mark all onboarding steps as seen
for existing users to avoid unnecessary popups during development.

Developers should create a new user in development environment
to test the onboarding steps.
2025-03-13 14:38:16 -07:00
Vector73
b31024be47 saved_snippets: Add support for editing saved snippets.
Fixes #33708.
2025-03-13 10:58:36 -07:00
Vector73
c049259d07 user: Remove is_billing_admin user property.
Removed `is_billing_admin` user property as it is no longer used since
billing permissions are now determined by `can_manage_billing_group`
realm setting.
2025-03-10 09:36:30 -07:00
sanchi-t
200606902a stream: Send archived channels for non-subscribed channels.
Allows admins to view archived streams of non-subscribed
channels in the channel settings.
2025-03-07 18:08:41 -08:00
Shubham Padia
8481dcedc4 stream: Do not pass user group object when changing group setting.
Passing the user group object in case of named user group is fine for
`do_change_stream_group_based_setting`. But for anonymous groups, if the
code path calling that function is not creating a new anonymous user
group, it has to modify the user group by itself before calling that
function. In that case, if `old_setting_api_value` is not provided,
`old_user_group` is calculated false, since the group id has not changed
for the stream, but the group membership has changed.
old_setting_api_value will be the same as new_setting_api_value in such
a case.
It is better to accept the new setting value as either an int or
UserGroupMembersDict, so that `do_change_stream_group_based_setting` can
decide what to do with that argument.
2025-03-04 11:34:59 -08:00
Sahil Batra
75b5d43a91 groups: Rename AnonymousSettingGroupDict to UserGroupMembersDict.
This change is done because we would use the same data structure
for named user groups as well in future commits.
2025-02-27 10:03:28 -08:00
Mateusz Mandera
9649e0d7c0 presence: Fix for last active time for invisible mode.
Co-authored-by: Tim Abbott <tabbott@zulip.com>
2025-02-26 12:51:57 -08:00
Shubham Padia
e57c43b705 bots: Do not remove bot from inaccessible streams on owner change.
See
https://chat.zulip.org/#narrow/channel/101-design/topic/manage.20bot.20access.20feature.20removal
2025-02-26 09:30:24 -08:00
Saubhagya Patel
d0c5c1cacb settings: Add backend to change allow_edit_history to integer field.
This commit implements the backend of migrating the
`allow_edit_history` setting to
`message_edit_history_visibility_policy`.
This allows organizations, to have an intermediate setting to
view only the "Moves" history of the messages.

We still pass `realm_allow_edit_history` in `/register` response
though for older clients with its value being set depending on the
value of `realm_message_edit_history_visibility_policy`. We set
`realm_allow_edit_history` to `False` if the
`realm_message_edit_history_visibility_policy` is "None", and
`True` for "Moves only" or "All" message edit history.

Fixes part of #21398.

Co-authored-by: Shlok Patel <shlokcpatel2001@gmail.com>
Co-authored-by: Tim Abbott <tabbott@zulip.com>
2025-02-25 18:18:23 -08:00
Vector73
2ef9695ef0 settings: Migrate wildcard_mention_policy to group-based permission.
Added new group-based permission setting
`can_mention_many_users_group` to replace `wildcard_mention_policy`.
2025-02-12 23:21:33 -08:00