Commit Graph

9200 Commits

Author SHA1 Message Date
Niloth P
4975f5b0fa integrations: Remove Jenkins from the Python API integrations' dict.
Jenkins is a plugin integration, that had been mistakenly marked as a
PythonAPIIntegration.
2025-03-26 11:19:31 -07:00
Tim Abbott
f3a829ce71 notifications: Complete old compatibility TODO.
We no longer support upgrading from old enough versions that bots
should get here, which means we can move to the more compact assert
statement.
2025-03-26 10:54:38 -07:00
Shubham Padia
2e48293e4b streams: Use bulk function in can_access_stream_metadata_user_ids.
Performance remains the same whether we're using the bulk function
underneath the function in question or not, this helps us avoid
duplication.
2025-03-25 13:20:06 -07:00
Shubham Padia
b62d51f0ae streams: Add get_metadata_access_streams_via_group_ids. 2025-03-25 13:20:06 -07:00
Shubham Padia
139679cdb1 user_groups: Add get_recursive_supergroups_union_for_groups.
This function will be useful in finding out affected groups when
sending events for users gaining or losing metadata access when the
members of a user group change in any way.
2025-03-25 13:20:06 -07:00
Shubham Padia
208ee1b8d9 streams: Add bulk_access_stream_metadata_user_ids.
This function will be useful in sending events for users gaining or
losing metadata access when the members of a user group change in any
way.
2025-03-25 13:20:06 -07:00
Aman Agrawal
e6dd79f241 registration: Fix language code missing for find_team emails.
If there were no users found for `find_team`, we need to provide
a default langauge for the email as one cannot be extracted from
`UserProfile` in this case.
2025-03-24 14:41:23 -07:00
Alex Vandiver
74d6f033b0 message: Enforce no parallel bitmap heap scans. 2025-03-24 09:30:11 -07:00
Alex Vandiver
70ed1ee46c message: Move join to recipients outside of LIMIT, via CTE. 2025-03-24 09:30:11 -07:00
Alya Abbott
17159cd062 updates: Add update message (level=15). 2025-03-20 11:44:33 -07:00
PieterCK
719f8db654 migration_status: Refactor parse_migration_status.
This refactors `parse_migration_status` to copy the algorithm of
Django's `showmigrations` command instead of parsing its output. This is
done so that the code is not susceptible to breaking changes if Django
modifies showmigrations's implementation.

The previous `parse_migration_status` logic has been repurposed into a
test utility function (`prase_showmigrations`). It is used to verify
that the new `parse_migration_status` generates output identical to the
actual `showmigrations` command.

The `test_clean_up_migration_status_json` is removed because
`test_parse_migration_status` has covered that behavior.
2025-03-20 10:57:54 -07:00
Prakhar Pratyush
9a46104684 addressee: Rename "(no topic)" to empty string topic.
This commit renames "(no topic)" to "" when used as
topic name, while sending or scheduling messages.

This is particularly helpful for older clients where
sending messages with empty topic input box resulted
in messages being sent to "(no topic)" topic.

Now, it will be sent in empty string topic and will
appear in the "general chat" topic.

This helps older clients to somewhat align with the UX
of the clients supporting empty string topic.
2025-03-19 11:39:28 -07:00
Lauryn Menard
a4fff91e96 signup: Add "airsi.de" as an allowed email domain.
Renames WHITELISTED_EMAIL_DOMAINS to OVERRIDE_ALLOW_EMAIL_DOMAINS
as the set of email domains that are allowed even if they are in
the set of disposable email domains.
2025-03-19 10:04:11 -07:00
Alex Vandiver
1eb4b65b5a queue: Round-trip events through orjson in tests.
This ensures that tests don't rely on non-JSON'able datatypes being
able to be put in an event.
2025-03-18 11:53:51 -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
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
Alex Vandiver
d978363a75 topic: Enforce is_channel_message=True on topic queries. 2025-03-18 09:34:11 -07:00
Alya Abbott
33ffd8c040 updates: Add update message (level=14). 2025-03-17 18:58:24 -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
6def6cb77a user_topics: Use a list instead of tuple for muted_topics.
Tuple is converted into a list by orjson, which in turn causes mismatch
in the initial state and the hybrid state after using apply_events.
Using a list instead helps us prevent that.
2025-03-17 14:21:37 -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
Lauryn Menard
e853f3cb9b help: Rename and redirect "Edit a bot" to "Manage a bot".
Fixes #32887.

Co-authored-by: ahmedgulabkhan <demoncommand97@gmail.com>
2025-03-17 10:52:25 -07:00
Sahil Batra
5915b85c5a register: Optimize computing stream group setting values.
Fetch all anonymous groups data once which can be used
for computing group setting values for realm, streams
and user groups.

Fixes #32561.
2025-03-14 18:31:18 -07:00
Sahil Batra
bc2afd45b3 streams: Refactor code to handle group setting values.
This commit updates the code which computes the dict for
setting groups mapping named user groups to ID and anonymous
groups to UserGroupMembersDict. After the changes, the dict
contains only anonymous groups values and the setting values
for group IDs not present in dict will be computed based on
the fact that those are named user groups.

This is a preparatory refactor for optimizing computing group
setting values for register response by fetching all anonymous
groups membership data just once.
2025-03-14 18:31:18 -07:00
Anders Kaseorg
88a8087243 ruff: Fix PYI019 Use Self instead of custom TypeVar.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-03-14 17:31:50 -07:00
Anders Kaseorg
67fb7daa63 ruff: Fix RUF051 Use pop instead of key in dictdel dict[key].
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-03-14 17:31:50 -07:00
Anders Kaseorg
cb0560d734 narrow: Add access restrictions to get_base_query_for_search.
This mirrors the restrictions in
zerver.lib.message.bulk_access_stream_messages_query, in order to
prevent leftover UserMessage rows from granting access to messages the
user was previously allowed to access but no longer is.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-03-14 16:24:34 -07:00
Anders Kaseorg
dc22b5d4bf narrow: Remove get_base_query_for_search need_message optimization.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-03-14 16:24:34 -07:00
Anders Kaseorg
5a56b53689 narrow: Add flags column outside get_base_query_for_search.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-03-14 16:24:34 -07:00
Prakhar Pratyush
7cd0fc645b onboarding: Add navigation_tour_video_text in initial DM by welcome bot.
This commit adds a line in the initial DM sent to new users by
the welcome bot regarding the new navigation tour video.
2025-03-13 14:38:16 -07:00
Prakhar Pratyush
5f3896710f onboarding_steps: Add 'navigation_tour_video' for new users.
This commit adds a one-time modal to display navigation tour
video to new users.

Includes an `NAVIGATION_TOUR_VIDEO_URL` server-setting to specify
the video's URL. When set to None, the modal is not displayed.

Fixes #29304.
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
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
0053c64f37 groups: Anonymous group member and subgroup IDs should be sorted.
We now return the members and subgroups ID list sorted for
settings that are set to anonymous groups. This is needed to
make sure we do not show save discard buttons when only pill
order is changed.
2025-03-12 17:18:05 -07:00
Sahil Batra
943e754a90 streams: Do not include deactivated users in group setting values.
This commit fixes the code to not include deactivated groups in
stream setting values when the setting is set to an anonymous
group. This is consistent with what we do for realm and user
group settings.

As a result, we also deduplicate some code by using existing
function used for realm and group settings.
2025-03-12 17:14:05 -07:00
Aman Agrawal
eae11d9056 user-group: Use 2 user cog icon for user group settings. 2025-03-12 09:14:37 -07:00
Tim Abbott
887e3faa31 narrow: Fix -in:home logic when nothing is muted.
This didn't have test coverage, and was incorrectly a noop.
2025-03-11 23:18:07 -07:00
opmkumar
4f462970e4 search: Add is-muted search operator.
Add the `is:muted` search operator.
`-is:muted` is an alias for the `in:home` operator.

Co-authored-by: Kenneth <Kenneth012004@outlook.com>

Fixes #16943
2025-03-11 23:18:07 -07:00
Tim Abbott
9849048d6e message_edit: Add last_moved_timestamp to API message objects.
This will allow clients to display MOVED/EDITED indicators, and their
tooltips, without interacting with the `edit_history` section of
message objects, which we plan to remove in the future.

Supporting that requires both introducing both last_moved_timestamp,
and changing the definition of last_edit_timestamp to not include
message moves, which involves recalculating it at the API layer.

The last_moved_timestamp is not present if the topic moves for the
message are for resolving or unresolving the topic. It is always
present for channel moves.

Co-authored-by: Lauryn Menard <lauryn@zulip.com>
2025-03-11 16:42:28 -07:00
Lauryn Menard
345ea92b01 help: Document org setting to allow viewing only message moves.
Documents organization setting that configures what message edit
history can be viewed: content edits and topic/channel moves, only
topic/channel moves, or disabling viewing edit history completely.

Renames article to match new help article header and creates URL
redirect for previous article header.

Also, clean up and consolidate related articles.

Fixes #33684.

Co-authored-by: Alya Abbott <alya@zulip.com>
2025-03-11 12:26:21 -07:00
Alex Vandiver
721fd26442 send_email: Set the Date header according to local enqueue time.
Email clients tend to sort emails by the "Date" header, which is not
when the email was received -- emails can be arbitrarily delayed
during relaying.  Messages without a Date header (as all Zulip
messages previously) have one inserted by the first mailserver they
encounter.  As there are now multiple email-sending queues, we would
like the view of the database, as presented by the emails that are
sent out, to be consistent based on the Date header, which may not be
the same as when the client gets the email in their inbox.

Insert a Date header of when the Zulip system inserted the data into
the local queue, as that encodes when the full information was pulled
from the database.  This also opens the door to multiple workers
servicing the email_senders queue, to limit backlogging during large
notifications, without having to worry about inconsistent delivery
order between those two workers.

Messages which are sent synchronously via `send_email()` get a Date
header of when we attempt to send the message; this is, in practice,
no different from Django's default behaviour of doing so, but makes
the behaviour slightly more consistent.
2025-03-10 16:48:08 -07:00
Sahil Batra
d8bc2f350e settings: Remove conditions for dense_mode setting. 2025-03-10 16:07:37 -07:00
Mateusz Mandera
c031cf9275 import: Fix export/import of SavedSnippet.
This table's export and import weren't working:
1. It didn't have a Config in export.py, so it wasn't exported at all.
2. Its `date_created` wasn't registered in `DATE_FIELDS`.
3. It wasn't registered in `ID_MAPS` in import_realm.py, so having any
   SavedSnippets in the export would cause the import to fail with an
   exception.
4. It was missing a `fix_datetime_fields` call in its import codepath.
2025-03-10 13:07:56 -07:00
Mateusz Mandera
acb1731bf9 export: Fix export of child tables when exporting mirror dummy users.
Without this change, the child tables of UserProfile didn't get their
objects exported if those objects were tied to a mirror dummy user.

For example, a `Recipient` of type `PERSONAL`, or the associated
`Subscription` would not get exported. Same for other tables with
foreign keys to `UserProfile` - such as `UserPresence`.

This happened because the Configs for the export are defined as follows:

```python
user_profile_config = Config(
    custom_tables=[
        "zerver_userprofile",
        "zerver_userprofile_mirrordummy",
    ],
    # set table for children who treat us as normal parent
    table="zerver_userprofile",
    virtual_parent=realm_config,
    custom_fetch=custom_fetch_user_profile,
)

user_subscription_config = Config(
    table="_user_subscription",
    model=Subscription,
    normal_parent=user_profile_config,
    filter_args={"recipient__type": Recipient.PERSONAL},
    include_rows="user_profile_id__in",
)

Config(
    table="_user_recipient",
    model=Recipient,
    virtual_parent=user_subscription_config,
    id_source=("_user_subscription", "recipient"),
)
```

while in `export_from_config` we have:
```python
    elif config.normal_parent:
        # In this mode, our current model is figuratively Article,
        # and normal_parent is figuratively Blog, and
        # now we just need to get all the articles
        # contained by the blogs.
        model = config.model
        assert parent is not None
        assert parent.table is not None
        assert config.include_rows is not None
        parent_ids = {r["id"] for r in response[parent.table]}
```

This meant that when processing a table with
`normal_parent=user_profile_config`, the `parent_ids` above would only
have the ids of `UserProfile` objects under the `zerver_userprofile` key in
the exported data - completely missing those in
`zerver_userprofile_mirrordummy`.
2025-03-10 13:07:56 -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
Tim Abbott
e9334abbf4 events: Reorder fetch_initial_state_data. 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
583ec00db7 zulip_update_announcements: Add missing close-paren. 2025-03-10 09:19:51 -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
Tim Abbott
c58f14b159 streams: Allow editing subscriptions in archived channels.
Since this does impact the ability to access the channel's content, it
makes sense to permit changing subscriptions, just like other
permissions settings on the archived channel.
2025-03-07 18:08:41 -08:00