Commit Graph

95 Commits

Author SHA1 Message Date
Anders Kaseorg
e82b9140ed emoji: Remove setting for deprecated Google blobs emoji set.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit b742ab18f9)
2025-10-14 11:54:10 -07:00
Mateusz Mandera
58427f8ed1 external_auth_id: Add new unique constraint. 2025-08-12 12:10:45 -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
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
Mateusz Mandera
a61d849e37 ldap: Implement external auth id auth+sync.
Fixes #24104.
2025-07-09 15:31:17 -07:00
Aditya Kumar Kasaudhan
cc9d78328e users: Add SECURITY_SENSITIVE_USER_SETTINGS to UserBaseSettings.
This commit is a preparatory step for allowing organization owners to
reset user preferences, defines a set of sensitive user settings
that will be protected from resets by organization owners.
2025-07-07 09:48:25 -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
opmkumar
87d14086af settings: Add web_left_sidebar_unreads_count_summary setting.
Co-authored-by: Akarsh Jain <akarsh.jain.790@gmail.com>

Fixes part of #28759.
2025-06-27 13:50:15 -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
Aman Agrawal
f4e6f2f89b events: Add option to send partial data.
Server can now send partial data to the client to help in
developement. We don't want this to be widely used right now,
hence no documentation changes have been made.

This will likely be a check on client capability later.
2025-05-19 16:58:56 -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
45d2c8acf5 users: Add parameter to fetch user data for a list of user ids.
This will help us defer loading user data from initial app load
to later when the user data is required.
2025-05-12 15:49:43 -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
Shubham Padia
b8ba174455 users: Return true for admins for is_moderator.
This change is for consistency with how is_admin works.

API design discussion at https://chat.zulip.org/#narrow/channel/378-api-design/topic/Should.20is_moderator.20have.20admins
2025-04-22 11:24:49 -07:00
Sahil Batra
d34bdf8af5 users: Fix comment for base_bulk_get_user_queryset.
We no longer fetch can_access_all_users_group using
select_related after #34356.
2025-04-16 09:02:45 -07:00
Sahil Batra
c5b005833c groups: Do not prefetch can_access_all_users_group setting.
This commit updates code to not prefetch can_access_all_users_group
and can_access_all_users_group__named_user_group fields using
select_related. We can just use get_realm_system_groups_name_dict
function to check if setting is set to "Everyone" group when
needed and can avoid unnecessarily fetching groups for every user
query.
2025-04-11 17:37:06 -07:00
Sahil Batra
7ebea853be user_groups: Refactor user_has_permission_for_group_setting.
This commit refactors user_has_permission_for_group_setting
to accept setting group ID instead of UserGroup object.

We only need ID in checking the permission and this helps in
further commit to avoid prefetching can_access_all_users_group
setting.
2025-04-11 17:37:06 -07:00
Sahil Batra
f29166dbba settings: Do not pre-fetch DM permission group settings.
This commit updates code to not pre-fetch DM permission
group settings using select_related and instead just
fetch the required data from DB when checking permission.

This will increase one query but will help in pre-fetching
the settings for all users and for all type of messages.

Fixes part of #33677.
2025-04-07 15:34:30 -07:00
roanster007
2c548d4856 settings: Allow "resolve topic" permissions to be managed independently.
This commit separates the "resolve topic" permissions from the
topic editing permissions, through the introduction of setting -
"can_resolve_topics_group" which user group whose members
can resolve topics.

Fixes #21811
2025-03-12 19:32:35 -07:00
Sahil Batra
e2d9d069e0 settings: Remove dense_mode setting. 2025-03-10 16:07:37 -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
Vector73
158fd58cde settings: Add "can_manage_billing_group" realm setting.
Added "can_manage_billing_group" realm group permission setting
to control who can manage billing and plans in the organization.

Fixes #32745.
2025-03-10 09:36:30 -07:00
Alex Vandiver
adbdbee26b cache: Rename user_profile_cache_key to be more specific. 2025-02-13 12:40:53 -08:00
Alex Vandiver
11c32dcfb2 cache_helpers: Fill the narrow-user cache as well. 2025-02-13 12:40:53 -08:00
Alex Vandiver
392f7556dd users: Use the same select_related for API-key and by-id user loads.
These were likely mistakenly left off of 6098c2cebe, leading to
1847086044 likely not switching to `base_get_user_queryset` for this
function because the list differed.
2025-02-13 12:40:53 -08:00
Alex Vandiver
f58c29b290 presence: Use the narrow user cache.
These two endpoints make up ~85% of requests to Zulip servers; since
presence is also a performance-critical endpoint, having them share
the same cache increases how hot it stays in memcached, in addition to
making the presence endpoint faster.

This comes at the very slightly cost of one extra field.  Checks
for the `is_bot` column are switched to the equivalent `bot_type`
check, since the columns are slightly duplicative, and we can get away
with only checking bot_type.
2025-02-13 12:40:53 -08:00
Alex Vandiver
58bf2a7935 tornado: Limit the width of the user queries, when they're needed.
Tornado requests try hard to not make SQL queries -- and if they're
necessary, to minimize the number of them.  Specifically, both session
objects and user objects are cached in memcached, and we expect that
both of them will have been filled there by Django before any requests
are made to Tornado.

In the event that memcached is flushed, or data is otherwise evicted,
we perform two database queries -- one for the session, and one for
the user.  However, the *width* of the latter query has grown
significantly over time, as the Realm object grew more fields, and
recently with the addition of role groups, which require multiple
joins each.  This leads to a query which is over 12k of text long, and
results in 319 columns.  In the event of a memcached flush, this can
result in a *significant* amount of SQL traffic, as nearly every
active Tornado request will make that query.

We do not wish to narrow the default query for Django; we instead tag
the request in the REST wrapper, and use that to use a much narrower
user cache entry.  That narrower cache entry is filled before the
queue is created in Django; we also use it to explicitly set the log
data, so the second "half" of the continued Tornado request does not
need to fetch any user data either when writing its log line.

Because they use different cache keys, this only affects the
session-based `/json/events` endpoint, which caches by user-id; the
`/api/v1/events` endpoint, which uses an API-key cache, keeps its wide
user object.  The former is 50% of the total request volume, whereas
the latter is only 2%, so adding an additional cache for it is
unnecessary complexity.
2025-02-13 12:40:53 -08:00
Sahil Batra
7eeb8a2c26 settings: Add personal setting to show or hide AI features.
Fixes #33231.
2025-02-12 12:05:04 -08:00
Sahil Batra
4ca28bb850 settings: Add setting to control permission for topic summarization. 2025-02-12 12:05:04 -08:00
Vector73
d48164ce1e settings: Add two new realm settings to restrict bot creation.
Added `can_create_bots_group` setting which controls who can
create any type of bots in the organization.

Added `can_create_write_only_bots_group` setting which controls
who can create incoming webhooks in the organization in additon
to those who are in `can_create_bots_group`.
2025-01-30 11:37:33 -08:00
Shubham Padia
e912ada51e stream: Rename can_subscribe_others_to_all_streams.
Rename `can_subscribe_others_to_all_streams` to
`can_subscribe_others_to_all_accessible_streams` so it's clear that we
are not attempting to check basic access in this function.
2025-01-27 11:26:06 -08:00
Anders Kaseorg
f52ec0559c realms: Use modern union syntax for property_types.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-01-24 23:00:21 -08:00
Shubham Padia
41c74314c0 streams: Use can_add_subscribers_group for permission check.
The function to check relevant permissions does so for multiple streams
at once to save us database query counts. Doing it one by one for every
stream would become very expensive.
We've also added `insufficient_permission_streams` to the filter
functions return type for streams for which the current user does not
have permission to subscribe other users.
2025-01-22 14:27:06 -08:00
Shubham Padia
275a1a4c69 realm: Use can_add_subscribers_group instead of invite_to_stream_policy.
We remove `invite_to_stream_policy` from the backend wherever applicable
except deleting the field. We have just ported the existing behaviour of
`invite_to_stream_policy` to `can_add_subscribers_group` except one
change. We have added an explicit exception for admins to have this
permission whether they are part of this group or not. The reason for
this is we are adding `stream.can_add_susbcribers_group` in the future
which will grant all admins permission to subscribe other users to a
channel given they have access to a channel. So it makes sense that we
add this exception to the realm level property also.
See https://chat.zulip.org/#narrow/channel/101-design/topic/Can.20subscribe.20other.20users.20on.20user.20profile/near/2039825
2025-01-22 12:33:58 -08:00
Sahil Batra
9682e35584 settings: Show avatar by default in right sidebar for new orgs.
This commit sets the default for user_list_style to
USER_LIST_STYLE_WITH_AVATAR so that the organization
level defaults for new users of this setting is set
to show avatar in right sidebar for new orgs.
2025-01-09 09:19:22 -08:00
Kislay Verma
00df8a593d user_settings: Add field web_suggest_update_timezone.
This field tracks whether the user should be shown an
alert offering to update their profile time zone to the
time zone of the browser in case they differ.

The field is added to RealmUserDefault and UserProfile
models with a default value of True.

Fixes part of #16957
2024-12-13 12:58:07 -08:00
bedo
1847086044 subscription: Remove unnecessary select_related fields and clean up.
Removes the unnecessary fields from bulk_access_users_by_email and
bulk_access_users_id, while also removing duplication of these lists
of fields.

"base_bulk_get_user_queryset", used when fetching a user
other than the acting user.

"base_get_user_queryset", used when fetching the acting user,
prefetching more fields.

There remains some inconsistency in the models.py functions that may
merit further investigation.
2024-12-05 17:02:07 -08:00
Shubham Padia
0cc200e573 stream: Only realm admins can change default channels. 2024-12-04 12:25:19 -08:00
Vector73
4e89b4a88c settings: Add can_invite_users_group realm setting.
Added `can_invite_users_group` realm setting to replace
`invite_to_realm_policy`.
2024-11-20 13:35:05 -08:00
Vector73
1ba1408b01 settings: Remove edit_topic_policy setting.
Removed `edit_topic_policy` property, as the permission
to move messages between topcis is now controlled by
`can_move_messages_between_topics_group` setting.
2024-10-29 16:27:04 -07:00
Vector73
ed5638ec3c settings: Add can_move_messages_between_topics_group realm setting.
Added `can_move_messages_between_topics_group` realm setting to replace
`edit_topic_policy`.
2024-10-29 16:27:04 -07:00
Mateusz Mandera
389b851f81 update_user_backend: Allow authorized org owners to change user emails.
This adds a new special UserProfile flag can_change_user_emails(disabled
by default) and the ability for changing the email address of users in
the realm via update_user_backend. This is useful for allowing
organizations to update user emails without needing to set up a SCIM
integration, but since it gives the ability to hijack user accounts, it
needs to be behind this additional permission and can't be just given to
organization owners by default. Analogical to how the
create_user_backend endpoint works.
2024-10-22 16:36:38 -07:00
Vector73
68dc914b6e users: Refactor has_permission function.
Refactored `has_permission` function to programmatically check if the `policy_name`
is a group-based setting.
2024-10-16 14:26:20 -07:00
Vector73
8d341d1af9 settings: Remove move_messages_between_streams_policy setting.
Removed `move_messages_between_streams_policy` property, as the permission
to move messages between channels is now controlled by
`can_move_messages_between_channels_group` setting.
2024-10-16 14:26:20 -07:00
Vector73
1be0cb1b75 settings: Add can_move_messages_between_channels_group realm setting.
Added `can_move_messages_between_channels_group` realm setting to replace
`move_messages_between_streams_policy`.
2024-10-16 14:26:18 -07:00
Vector73
6bc8651d22 settings: Remove add_custom_emoji_policy setting.
Removed `add_custom_emoji_policy` setting as the permission to
add custom emoji is now controlled by `can_add_custom_emoji_group`
setting.
2024-10-13 16:09:04 -07:00
Vector73
f733ab112c settings: Add can_add_custom_emoji_group realm setting.
Added `can_add_custom_emoji_group` setting to replace `add_custom_emoji_policy`.
2024-10-13 16:09:04 -07:00
Mateusz Mandera
8e51442043 users: Add ROLE_TO_ACCESSIBLE_EMAIL_ADDRESS_VISIBILITY_IDS dict.
This is helpful for taking an "acting user" and getting the list of
email_address_visibility values such that the UserProfiles with those
values of the setting permit the acting user to view their
deliver_email.

This can be used for a query "all users whose delivery_email is viewable
by <requester>" in an upcoming commit.

The added code is ugly, but at least it lets us simplify some similarly
ugly logic in can_access_delivery_email.
2024-10-08 18:01:49 -07:00
Shubham Padia
0634f75582 settings: Rearrange group settings in alphabetical order. 2024-10-04 11:15:01 -07:00
Shubham Padia
91edf59873 settings: Rename can_edit_all_user_groups to use manage.
Having both `manage` and `edit` terminologies was confusing, so
this commit ensures that we use `manage` wherever applicable.
2024-10-01 17:35:14 -07:00