Commit Graph

18514 Commits

Author SHA1 Message Date
Alex Vandiver e73e44402a export_search: Support --dm with one user, for all their DMs. 2024-05-24 10:49:52 -07:00
Alex Vandiver 2218de0399 management: Disable Sentry for management commands run interactively.
This adds `--automated` and `--no-automated` flags to all Zulip
management commands, whose default is based on if STDIN is a TTY.
This enables cron jobs and supervisor commands to continue to report
to Sentry, and manually-run commands (when reporting to Sentry does
not provide value, since the user can see them) to not.

Note that this only applies to Zulip commands -- core Django
commands (e.g. `./manage.py`) do not grow support for `--automated`
and will always report exceptions to Sentry.

`manage.py` subcommands in the `upgrade` and `restart-server` paths
are marked as `--automated`, since those may be run semi-unattended,
and they are useful to log to Sentry.
2024-05-24 10:30:16 -07:00
Alex Vandiver 88be3246a0 management: Move commands to all use ZulipBaseCommand. 2024-05-24 10:30:16 -07:00
Alex Vandiver 174ae2b409 zulip_update: Catch and carry on if a realm fails.
It is better to log the exception and _try_ all realms, than to fail
early due to a bad realm and fail to notify the rest.
2024-05-24 10:21:45 -07:00
Alex Vandiver 5c2fd1de5a docs: Update Django links to our current version. 2024-05-24 10:18:37 -07:00
Prakhar Pratyush 0ce79c8c50 message_edit: Update do_update_message codepath to send event on commit.
Earlier, we were using 'send_event' in 'do_update_message'
which can lead to a situation where we enqueue events but
the transaction fails at a later stage.

Events should not be sent until we know we're not rolling back.
2024-05-24 10:17:35 -07:00
Prakhar Pratyush bca8338ee1 do_update_embedded_data: Change send_event to send_event_on_commit.
Earlier, we were using 'send_event' which can lead to a situation
where we enqueue events but the transaction fails at a later stage.

Events should not be sent until we know we're not rolling back.
2024-05-24 10:17:35 -07:00
Alex Vandiver e5a0b3b3c5 zilencer: Disambiguate no MX records from the domain not existing.
This switches to dnspython, since it offers the higher-level
`resolve_name` method to look up both A and AAAA records, and set
timeouts.
2024-05-24 09:34:31 -07:00
Alex Vandiver 9d66a8eb73 zilencer: Give a better error message for foo@example.com emails. 2024-05-24 09:34:31 -07:00
Vector73 62dfd93a83 api: Add "users/<int:user_id>/status" endpoint.
The documentation Creates a shared UserStatus schema that's used for
the return value of this new endpoint and for the existing user_status
objects returned by the register queue endpoint.

Co-authored-by: Suyash Vardhan Mathur <suyash.mathur@research.iiit.ac.in>

Fixes #19079.
2024-05-22 18:07:22 -07:00
Vector73 d6672c57ff user_status: Rename `get_user_status_dict` function.
Renames `get_user_status_dict` function to `get_all_users_status_dict`
to distinguish it from new `get_user_status` function.
2024-05-22 18:07:22 -07:00
Sahil Batra d1bcac0822 realm: Use enums for accessing setting values.
This commit updates code, majorly in tests, to use
setting values from enums instead of directly using
the constants defined in Realm.

We still have those constants defined Realm as they
are used in a couple of places where the same code
is used for different settings. These will be
handled later.
2024-05-22 17:20:37 -07:00
Sahil Batra 52b0199189 realm: Migrate "PATCH /realm" endpoint to typed_endpoint. 2024-05-22 17:20:37 -07:00
Sahil Batra 5d3a0ce94a realm: Add enums for setting values.
This is a prep commit to migrate "PATCH /realm" endpoint to use
"typed_endpoint".
2024-05-22 17:20:37 -07:00
Sahil Batra 5737d4c483 create_user: Fix comment in set_up_streams_for_new_human_user.
This commit fixes comment about subscribing to default streams
in set_up_streams_for_new_human_user to explain the current
logic after changes in 69ba580a54.
2024-05-22 11:34:27 -07:00
Prakhar Pratyush c91d018b38 user_topics: Make bulk_set_user_topic_..._in_database atomic.
In e726012244, we removed the
@transaction.atomic decorator from the function
'bulk_set_user_topic_visibility_policy_in_database'.

We should keep it to avoid adding it to the caller
of this function, when reused in the future.
2024-05-21 09:24:43 -07:00
Prakhar Pratyush 23c2ce1671 create_realm: Fix channel name and description not being translated. 2024-05-21 09:24:43 -07:00
Prakhar Pratyush 508c5611d1 claim_attachment: Remove the stale 'user_profile' parameter.
This commit removes the unused 'user_profile' parameter
of the 'claim_attachement' function.
2024-05-21 09:24:43 -07:00
Tim Abbott 330439a83b zulip_updates: Wrap differently to workaround bug.
The bold syntax appearing on the start of a line made this render badly.
2024-05-20 18:01:04 -07:00
Alya Abbott 0decaef284 updates: Add update about stream->channel rename and faster loading. 2024-05-20 16:31:55 -07:00
Sahil Batra 2007a582a1 message: Optimize checking if mentioning user group is allowed.
This commit updates the code to not call is_user_in_group
function if can_mention_group setting is set to "role:everyone"
group.
2024-05-20 14:43:07 -07:00
Sahil Batra eec80a4a5a message: Fix code to check group mention permission.
This commits fixes the code which checks group mention permission
to handle anonymous user groups correctly. Basically we were
not checking whether the UserGroup is linked to a NamedUserGroup
and directly accessing named_user_group which results in an
error.

We also update the error messages to include the group name
which has permission to mention the groups since now there
might be a comnbination of groups and users who has permission
to mention the group.

This commit also adds tests to check sending and editing messages
when can_mention_group is set to a anonymous user group.
2024-05-20 14:43:07 -07:00
Kenneth Rodrigues ba92cd8b23
search: Include history for is:resolved queries.
The previous logic assumed that all `is:` operators were those like `is:muted`
or `is:starred`, which depend on personal data.
2024-05-20 14:37:08 -07:00
Anders Kaseorg b545abe1e2 typos: Fix typos caught by mwic.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-05-20 13:55:00 -07:00
Anders Kaseorg 38cae070ed typos: Fix typos caught by typos.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-05-20 13:55:00 -07:00
Lauryn Menard c3577d9cdd api-docs: Update python example user-facing comments for channel.
Updates python usage example comments, which are user-facing, to
use channel instead of stream.

Part of the stream to channel rename project.
2024-05-20 11:30:25 -07:00
Lauryn Menard 016ffd8078 api-docs: Update python tests to not use "stream" in channel name.
Updates the channel names in python example tests to use "-channel"
instead of "_stream".

Part of stream to channel rename project.
2024-05-20 11:27:03 -07:00
Lauryn Menard c77c37be27 api-docs: Rename user-facing python example channel to "python-test".
Renames the test channel created and used in python usage examples
to "python-test" instead of "new stream".

Part of stream to channel rename project.
2024-05-20 11:27:03 -07:00
Lauryn Menard deec077925 api-docs: Update python usage example for archive_stream.
Even though there was a stream/channel ID being passed to the test
function for archive_stream, it wasn't being used in the test as
it was reset to a new stream created/subscribed in the function.

Updates the test function to remove the unused stream/channel ID
parameter, and updates the usage example for to use channel instead
of stream where appropriate.

Part of stream to channel rename project.
2024-05-20 11:27:03 -07:00
Lauryn Menard af5d618879 api-docs: Update comments in javascript usage examples for channel.
Updates comments that are displayed in the javascript examples for
various endpoints to use channel instead of stream.

Part of stream to channel rename project.
2024-05-20 11:27:03 -07:00
Lauryn Menard 7644c83cca api-docs: Update narrow usage examples for get_messages.
Updates narrow parameters in the javascript and python usage
examples for the get_messages endpoint to use the "channel"
operator instead of the "stream" operator.

Part of the stream to channel rename project.
2024-05-20 11:27:03 -07:00
Lauryn Menard f39e4e8087 api-docs: Change "streams" tag to "channels" in zulip.yaml. 2024-05-20 09:31:56 -07:00
Lauryn Menard 89af513d3a api-docs: Update /calls/bigbluebutton/create for channel.
Updates the API doc for /calls/bigbluebutton/create endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard c219136e4c api-docs: Update POST /typing for channel.
Updates the API doc for POST /typing endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 427b86aff6 api-docs: Update /streams/{stream_id}/delete_topic for channel.
Updates the API doc for /streams/{stream_id}/delete_topic endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard e29e4872f3 api-docs: Update /streams/{stream_id}/email_address for channel.
Updates the API doc for /streams/{stream_id}/email_address endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 06b18411fe api-docs: Update PATCH /streams/{stream_id} for channel.
Updates the API doc for PATCH /streams/{stream_id} endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 75b635d3bc api-docs: Update DELETE /streams/{stream_id} for channel.
Updates the API doc for DELETE /streams/{stream_id} endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard c45aba51aa api-docs: Update GET /streams/{stream_id} for channel.
Updates the API doc for GET /streams/{stream_id} endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 3d9a0aaf90 api-docs: Update GET /streams for channel.
Updates the API doc for GET /streams endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 2b71875676 api-docs: Update GET /streams/{stream_id}/members for channel.
Updates the API doc for GET /streams/{stream_id}/members endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard dfc6eab8a0 api-docs: Update PATCH /settings for channel.
Updates the API doc for PATCH /settings endpoint to use channel
in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 8a0c8cecf8 api-docs: Update GET /server_settings for channel.
Updates the API doc for GET /server_settings endpoint to use channel
in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard c87715a6ff api-docs: Update POST /register for channel.
Updates the API doc for POST /register endpoint to use channel
in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard f88fa28f55 api-docs: Update POST /invites/multiuse for channel.
Updates the API doc for POST /invites/multiuse endpoint to use channel
in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 8161bc16c8 api-docs: Update POST /invites for channel.
Updates the API doc for POST /invites endpoint to use channel in
descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard a4f4e61eef api-docs: Update POST /users/me/subscriptions/properties for channel.
Updates the API doc for POST /users/me/subscriptions/properties
endpoint to use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard b74ee5f740 api-docs: Update PATCH /realm/user_settings_defaults for channel.
Updates the API doc for PATCH /realm/user_settings_defaults
endpoint to use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 0fefbdd5b3 api-docs: Update DELETE /realm/emoji/{emoji_name} for channel.
Updates the API doc for DELETE /realm/emoji/{emoji_name}
endpoint to use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 66f93cf9d3 api-docs: Update /users/{user_id}/subscriptions/{stream_id} for channel.
Updates the API doc for /users/{user_id}/subscriptions/{stream_id}
endpoint to use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 9717aeea43 api-docs: Update /users/me/muted_users/{muted_user_id} for channel.
Updates the API doc for /users/me/muted_users/{muted_user_id} endpoint
to use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 880ab441f6 api-docs: Update POST /user_topics for channel.
Updates the API doc for POST /user_topics endpoint to use channel in
descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard c34e3a9eba api-docs: Update PATCH /users/me/subscriptions/muted_topics for channel.
Updates the API doc for PATCH /users/me/subscriptions/muted_topics
endpoint to use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 785b036a55 api-docs: Update DELETE /users/me/subscriptions for channel.
Updates the API doc for DELETE /users/me/subscriptions endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 8a75476cb6 api-docs: Update PATCH /users/me/subscriptions for channel.
Updates the API doc for PATCH /users/me/subscriptions endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 62cac75ebc api-docs: Update POST /users/me/subscriptions for channel.
Updates the API doc for POST /users/me/subscriptions endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 1f6a01eb28 api-docs: Update GET /users/me/subscriptions for channel.
Updates the API doc for GET /users/me/subscriptions endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard a090dc32a1 api-docs: Update /users/me/{stream_id}/topics for channel.
Updates the API doc for /users/me/{stream_id}/topics endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 559ba55690 api-docs: Update PATCH /messages/{message_id} for channel.
Updates the API doc for PATCH /messages/{message_id} endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard bc421afa25 api-docs: Update GET /messages/matches_narrow for channel.
Updates the API doc for GET /messages/matches_narrow endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 551791ca16 api-docs: Update POST /messages/flags for channel.
Updates the API doc for POST /messages/flags endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 03b0a8785a api-docs: Update GET /messages/{message_id}/history for channel.
Updates the API doc for GET /messages/{message_id}/history endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard fd9e9c6207 api-docs: Update POST /messages for channel.
Updates the API doc for POST /messages endpoint to use channel
in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard aea4216970 api-docs: Update GET /messages for channel.
Updates the API doc for GET /messages endpoint to use channel
in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard ce047d5c5a api-docs: Update DELETE /default_streams for channel.
Updates the API doc for DELETE /default_streams endpoint to use channel
in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 43cb33df1a api-docs: Update POST /default_streams for channel.
Updates the API doc for POST /default_streams endpoint to use channel
in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 4d0325da99 api-docs: Update /scheduled_messages/{scheduled_message_id} for channel.
Updates the API doc for PATCH /scheduled_messages/{scheduled_message_id}
endpoint to use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 3d33490a32 api-docs: Update descriptions in POST /scheduled_message for channel.
Updates the API documentation for the POST /scheduled_message endpoint
to use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 3c11872ebd api-docs: Update descriptions in POST /drafts for channel.
Updates the API documentation for the POST /drafts endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard ff49567c16 api-docs: Update descriptions in /mark_topic_as_read for channel.
Updates the API documentation for the /mark_topic_as_read endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard b8a91278f6 api-docs: Update descriptions in /mark_stream_as_read for channel.
Updates the API documentation for the /mark_stream_as_read endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 030863a585 api-docs: Update descriptions in /get_stream_id for channel.
Updates the API documentation for the /get_stream_id endpoint to
use channel in descriptions instead of stream.

Part of the stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 46b9456b31 api-docs: Use "Channel" for components schema names in zulip.yaml.
Part of stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard 6c643f2530 api-docs: Update descriptions in shared schemas to use channel.
Updates field descriptions in schema components and parameters to
use channel instead of stream.

Part of stream to channel rename project.
2024-05-20 09:31:56 -07:00
Lauryn Menard d44196bed2 api-docs: Update get-events description text to use channel.
Updates description's in /api/get-events to use channel instead
of stream.

Note that any shared schemas used for this endpoint's documentation
will be updated in other commits in this series.

Part of stream to channel rename project.
2024-05-20 09:31:56 -07:00
bedo acec5108c5 import/export: Map each message id to its attachments.
Fixes #29350
2024-05-20 09:18:49 -07:00
Prakhar Pratyush c798d192dc message_send: Update do_send_messages codepath to send event on commit.
Earlier, we were using 'send_event' & 'queue_json_publish' in
'do_send_messages' which can lead to a situation where we enqueue
events but the transaction fails at a later stage.

Events should not be sent until we know we're not rolling back.
2024-05-19 23:18:43 -07:00
Mateusz Mandera 27c4e46b30 do_deactivate_realm: Add deactivation_reason kwarg.
It's going to be helpful in the future to record the reason for realm
deactivation.
- For information tracking
- For making a distinction between cases where we can allow realm owners
  to reactivate their realm via a self-serve flow (e.g.
  "owner_request") vs where we can't (ToS abuse).
2024-05-19 23:07:28 -07:00
evykassirer 96c9950115 composebox_typeahead: Convert module to typescript. 2024-05-16 14:53:26 -07:00
Sahil Batra aa83812b1b user_groups: Rename are_both_setting_values_equal function.
This commit renames are_both_setting_values_equal function
to are_both_group_setting_values_equal to make it clear
that this function is used to compare value of group
settings.
2024-05-16 12:58:20 -07:00
Sahil Batra 7db7b3f94d groups: Move functions for updating settings to "lib.user_groups".
This commit moves validate_group_setting_value_change,
are_both_setting_values_equal and parse_group_setting_value
functions, which are used for updating the group settings, to
"zerver.lib.user_groups" as these functions will also be used for
group based realm and stream settings and "zerver.lib.user_groups"
file seems a better place to place such functions which are used
at multiple places.

For same reasons, we also move GroupSettingChangeRequest dataclass
to "zerver.lib.user_groups" file.
2024-05-16 12:58:20 -07:00
Tomas Fonseca 753b8e1f6f markdown: Added error handling for invalid time zones.
If an invalid timezone (such as +32h) was provided, the
timestamp.astimezone call would throw an exception, causing the
message send to fail. Replace that with a user-facing error.

Fixes #19658.
2024-05-16 09:38:25 -07:00
Aman Agrawal 7203661d99 support: Set discounted price instead percentage for customers.
This allows us to set the price of a plan exactly as discussed with
the customer.
2024-05-16 02:18:43 -07:00
Tim Abbott 1d52d08803 api_examples: Fix failing invitation links test.
This system is too fragile with hardcoded IDs; we should be asserting
that the preparatory requests succeeded to make these easier to debug.
2024-05-15 15:01:08 -07:00
Vector73 431beae96f api_documentation: Document "/invites/multiuse/{invite_id}" endpoint. 2024-05-15 12:05:40 -07:00
Lauryn Menard ab0fc402e0 api-docs: Update feature level 261 documentation.
The original changes for this feature level are in
commits a6be1d101 and 7b42c802b.
2024-05-15 21:01:05 +02:00
tnmkr 51635c81fc streams: Set creator for some initial streams in populate_db.
This is a follow-up to #29425. It assigns creator to three streams
that are used in tests and another two that aren't. For tests,
we assign a guest, an admin and an owner as creator.
2024-05-15 11:21:46 -07:00
Prakhar Pratyush e264b12066 zulip_updates: Send an introductory message before the first update.
To help users focus on the onboarding experience, we no longer
send the introductory "Zulip updates" message as a part of
onboarding.

Now, we send the introductory message just before the first
update message.

Fixes #30053.
2024-05-15 11:19:03 -07:00
Sahil Batra a85eb2110d test_message_move_topic: Define assert_has_visibility_policy once.
We just define assert_has_visibility_policy once instead of just
defining it in three different tests.
2024-05-15 10:57:23 -07:00
Sahil Batra 1811dd9b47 test_realm: Remove set_up_db.
This commit removes set_up_db, which called realm.save to
update the settings, and its calls are replaced with either
self.assertEqual (which is enough to verify the initial value)
or a "do_.." function call to set the setting to initial value.

It is better to avoid calling "realm.save" and instead use the
"do_.." functions to set the settings.

There are places where it is easy to just call "do_.." function
as default value is not the first value in the list of test values.
2024-05-15 10:57:23 -07:00
Sahil Batra 6e3c0690aa test_realm: Improve do_test_realm_update_api.
This commit improves how we handle video_chat_provider
and jitsi_server_url settings in do_test_realm_update_api.

For video_chat_provider, there is no use for calling
update_with_api_multiple_value and it can be handled
similar to other tests, so did that change and also
added one more value to test, so that it actually
tests changing the setting.

We need to handle jitsi_server_url separately as even
though value is a string, we need to serialize to
JSON. We do not use a separate function for it as
this is the only setting to handle differently and
update_with_api_multiple_value anyways was added in
bbff797a93 to update multiple settings in a request
which we are not doing here.

As a result of above changes, update_with_api_multiple_value
function is also removed.
2024-05-15 10:57:23 -07:00
Tim Abbott 7ec6f5296e migrations: Fix buggy migration failing to advance. 2024-05-14 16:54:06 -07:00
roanster007 80634eb32b message_send: Add forged_timestamp to internal_prep_stream_message.
This commit adds the "forged_timestamp" parameter to the
"internal_prep_stream_message" method of "actions/message_send".

This is a preparatory commit, that can be used for sending messages
at a forged time in scripts for generating screenshots of messages.
2024-05-14 16:17:44 -07:00
roanster007 0a7c0ea326 refactor: Relocate screenshots scripts to new tools/screenshots dir.
This commit relocates all the scripts in the tools directory which
are used for auto-generating screenshots to the new
tools/screenshots directory to avoid cluttering the tools/ root.
2024-05-14 16:17:44 -07:00
Sahil Batra 7b42c802b1 invites: Add include_realm_default_subscriptions parameter.
This commit adds include_realm_default_subscriptions parameter
to the invite endpoints and the corresponding field in
PreregistrationUser and MultiuseInvite objects. This field will
be used to subscribe the new users to the default streams at the
time of account creation and not to the streams that were default
when sending the invite.
2024-05-14 14:20:07 -07:00
Sahil Batra a6be1d1018 invites: Subscribe to default streams when not allowed to subscribe others.
This commit changes the code to subscribe the invited user to default
streams even if the user who invited the new user was not allowed to
subscribe others to streams.
2024-05-14 14:20:07 -07:00
Sahil Batra 8bca565218 groups: Pass old setting value for can_mention_group.
This commit adds support to pass object containing both old and new
values of the can_mention_group setting, as well as detailed API
documentation for this part of the API system.

Co-authored-by: Tim Abbott <tabbott@zulip.com>
Co-authored-by: Greg PRice <greg@zulip.com>
2024-05-14 12:17:15 -07:00
Sahil Batra 0cc2244aac groups: Migrate group creation and edit endpoints to typed_endpoint. 2024-05-14 12:17:15 -07:00
Sahil Batra 43810f76ea openapi: Fix typo in zulip.yaml. 2024-05-14 12:17:15 -07:00
Mateusz Mandera 160076fdfa import: Fix import of Stream.creator field.
When importing a Stream, UserProfiles don't yet exist. so trying to
import stream.creator fails with something like:

```
psycopg2.errors.ForeignKeyViolation: insert or update on table
"zerver_stream" violates foreign key constraint
"zerver_stream_creator_id_65aeba7e_fk_zerver_userprofile_id"
DETAIL:  Key (creator_id)=(5) is not present in table "zerver_userprofile".
```
2024-05-13 20:11:28 -07:00
Prakhar Pratyush 0cddc8a6a6 onboarding: Fix topic names not being translated correctly.
In 'send_initial_realm_messages', the topics names were not
being translated properly as they were computed outside the
with `override_language` block.

Now, we use 'send_initial_realm_messages' inside a with
'override_language' block in the caller. This fixes the bug.

Note: We are using 'override_language' block in the caller
and not within the function as it helps to avoid indenting
everything inside the function.
2024-05-13 16:06:10 -07:00
Prakhar Pratyush aad66674e7 onboarding: Fix the query for 'greetings_message'.
The query to fetch one of the greetings message based on
content wasn't taking translation into account that would
result in a bug in realms using non-english language.

This commit updates the query to fix the bug.
2024-05-13 16:06:10 -07:00
Alya Abbott 5aeeafd39c portico: Improve message for deactivated, invalid and moved orgs. 2024-05-13 12:44:20 -07:00
Alya Abbott 8a51c42c07 onboarding: Modify content on onboarding messages.
- Tighten up the content.
- Use pretty quotes.
- Reorder "experiments" topic to appear after "start a conversation"
  in Inbox.
- Drop reference to messages being starred (not implemented yet).
2024-05-12 17:24:17 -07:00
Prakhar Pratyush 15a7870d2e onboarding: Use 'remove_single_newlines' once, while sending message.
Instead of applying 'remove_single_newlines()' to individual
contents when declared, we use it once while prepping up
message in 'internal_prep_stream_message_by_name'.

Just for the code to be less finnicky.
2024-05-12 17:24:17 -07:00
Prakhar Pratyush 643998fcfa onboarding_steps: Rename 'hotspots' files to 'onboarding_steps'. 2024-05-10 12:30:22 -07:00
Prakhar Pratyush bf2360bcf2 onboarding_steps: Remove hotspot as an onboarding_step.
Earlier, hotspots and one-time notices were the valid
type of onboarding step.

Now, one-time notice is the only valid type.

Fixes #29296.
2024-05-10 12:30:22 -07:00
Prakhar Pratyush e8769f80a6 onboarding_steps: Rename 'copy_hotspots' function.
The function is used for any type of onboarding step
i.e. not limited to Hotspot.

This commit updates the function and variables name
to reflect the above mentioned behaviour.
2024-05-10 12:30:22 -07:00
Vector73 9f8d738252 openapi: Document android_gcm_reg_id endpoints.
This commit adds API documentation for "/users/me/android_gcm_reg_id:post"
and "/users/me/android_gcm_reg_id:delete" endpoints.

Co-authored-by: Suyash Vardhan Mathur <suyash.mathur@research.iiit.ac.in>
2024-05-10 08:37:12 -07:00
Vector73 b047bf0d79 openapi: Document apns_device_token endpoints.
This commit adds API documentation for "/users/me/apns_device_token:post"
and "/users/me/apns_device_token:delete" endpoints.

openapi: Document android_gcm_reg_id endpoints.

Co-authored-by: Suyash Vardhan Mathur <suyash.mathur@research.iiit.ac.in>
2024-05-10 08:37:12 -07:00
Prakhar Pratyush ac2152fdfd onboarding: Replace channel messages in new organizations.
As a part of improving onboarding experience, this
commit updates the channels and messages initially
available in new orgs.

Fixes #29297.
2024-05-09 14:05:35 -07:00
Prakhar Pratyush 7ea66dbec5 onboarding: Mark channel name for translation.
Mark the channel name of the initial channel created during
realm creation for translation.

It doesn't mark the topic names and description for translation
because we are planning to remove these topics and update the
description as a part of improving the onboarding experience.
2024-05-09 14:05:35 -07:00
Prakhar Pratyush 61e606f656 onboarding: Remove 'core team' private channel.
We no longer create the 'core team' private channel when
a realm is created.

Earlier, "New user announcements" channel was set to the
"core team" channel. Now it is disabled by default.

populate_db still creates the 'core team' channel to
represent a private channel.
2024-05-09 14:05:35 -07:00
Prakhar Pratyush 6baf981aa5 test_import_export: Fix a flaky test due to random reactions added.
The reactions added to messages in the test database are
random in nature, so there is a possibility of any number
of reaction records in the exported user data.

The test now verifies the reaction which was added in the test
itself.

Earlier, the test was assuming the reaction added in the test
is the only record in the exported data.

That would result in a flaky behavior. This commit fixes the
flaky behavior.
2024-05-09 14:05:35 -07:00
Prakhar Pratyush 20fbba6375 test_realm: Fix a flaky test due to random message populated.
The messages populated in the test database are random in nature,
so there is a possibility of any number of messages in
'new_stream_announcements_stream' in 'test_merge_streams'.

Earlier, the test was assuming of exactly one message in that
stream.

That would result in a flaky behavior. This commit fixes the
flaky behavior.
2024-05-09 14:05:35 -07:00
Prakhar Pratyush fd335c06eb test_message_fetch: Fix a flaky test due to random message populated.
The messages populated in the test database are random in nature,
so there is a possibility of more than one resolved topic
messages returned by 'self.get_and_check_messages()' query
in 'test_get_messages_for_resolved_topics'.

That would result in a flaky behavior. This commit fixes the
flaky behavior.
2024-05-09 14:05:35 -07:00
Mateusz Mandera 9406bfbc0a analytics: Store realm disk space used as a CountStat.
Fixes #29632.

The issue description explains this well:

We currently recalculate `currently_used_upload_space_bytes` every file
upload, by dint of calling `flush_used_upload_space_cache`  on
save/delete, and then immediately calling
`user_profile.realm.currently_used_upload_space_bytes()` in
`notify_attachment_update`.  Since this walks the Attachments table,
recalculating this can take seconds in large realms.

Switch this to using a CountStat, so we don't need to walk significant
chunks of the Attachment table when we upload an attachment.  This will
also give us a historical daily graph of usage.
2024-05-09 10:54:44 -07:00
Mateusz Mandera 4c4a443002 models: Add (realm, create_time) index for the Attachment table. 2024-05-09 10:54:44 -07:00
Mateusz Mandera 224ea3aaed retention: Add .restored_timestamp to ArchiveTransaction.
This is just generally useful for tracking and debugging.
2024-05-09 10:54:44 -07:00
Alex Vandiver a1a14527db migrations: Update 0516 to handle invites with non-default streams.
We update the existing migration, because any deployment which had
invitations with non-default streams in this state cannot have
proceeded past this migration yet.
2024-05-09 09:41:36 -07:00
Sahil Batra 3f80bc1b41 groups: Allow setting anonymous group to settings while editing.
This commit adds support to set can_mention_group setting to
anonymous group while editing groups.
2024-05-08 18:20:14 -07:00
Sahil Batra 23fdb73353 groups: Allow setting anonymous group to settings while creation.
This commit adds support to set can_mention_group setting to
anonymous group while group creation.
2024-05-08 18:20:14 -07:00
Sahil Batra 206014f263 groups: Update group objects to pass anonymous groups data for settings.
This commit updates code to handle the can_mention_group field
correctly if the setting is set to an anonymous user group.
2024-05-08 18:20:14 -07:00
Sahil Batra 6b68d7e80d user_groups: Update access_user_group_for_setting.
This commit updates access_user_group_for_setting
to support setting anonymous user groups for
different settings.

There are some lines without coverage as of this
commit, but the next few commits would add tests
covering those.
2024-05-08 18:20:14 -07:00
Sahil Batra ce9f4231c7 groups: Fix queries to get members and sugroups for user group objects.
This commit fixes the queries to get members and subgroups for
user group objects returned by user_groups_in_realm_serialized
to not include the UserGroup objects which are not linked to a
NamedUserGroup object, since the function only returns data for
NamedUserGroup objects.
2024-05-08 18:20:14 -07:00
Vector73 ac4dde24ae realm: Add an alias `realm_url` and deprecate `realm_uri` in the API.
The naming `uri` is deprecated while `url` should be used in order to
satisfy URL standards. For this reason, four endpoints are affected:

* The response content of three endpoints `/server_settings`,
`/register` and `/realm` that contain a field `realm_uri` is
changed to `realm_url`.

* In one of the common fields for all mobile push notifications payloads,
`realm_url` field is now added as an alias to `realm_uri`.

For backwards compatibility, we keep the field `realm_uri` and add
an alias `realm_url`.

Co-authored-by: Junyao Chen <junyao.chen@socitydao.org>
2024-05-08 17:39:15 -07:00
Prakhar Pratyush 00474608c5 zulip_update: Send group DM for realm imported from other product.
When the export is NOT generated by another zulip server,
while importing:
* Set the 'zulip_update_announcements_level' to the latest level
as we don't want to send all the older update messages to them.

* Send a group DM to admins, suggesting them to configure the
stream in order to avoid missing future update messages.

Fixes #29041.
2024-05-08 17:05:59 -07:00
Prakhar Pratyush cc793612f0 export: Create REALM_EXPORTED audit log for exports via shell.
Earlier, we were creating RealmAuditLog with REALM_EXPORTED
event_type when export of public data took place via organization
settings panel.

We were not creating the audit log when the export was executed
via shell i.e './manage.py export'.

This commit creates the audit log in that case too. It will
help during import to distinguish readily between imports
from another Zulip server vs imports from another product.
2024-05-08 16:16:37 -07:00
Vector73 8ab526a25a models: Replace realm.uri with realm.url.
In #23380, we are changing all occurrences of uri with url in order to
follow the latest URL standard. Previous PRs #25038 and #25045 has
replaced the occurences of uri that has no direct relation with realm.

This commit changes just the model property, which has no API
compatibility concerns.
2024-05-08 11:12:43 -07:00
Prakhar Pratyush 5b3641d92d help: Move 'channels-and-topics' to 'introduction-to-topics'.
Introduction to channel is now moved out as a new article,
the 'channel-and-topics' contains only introduction to topics,
hence renamed.
2024-05-07 16:51:48 -07:00
Alya Abbott 318cb2bfce help: Create an introduction to channels page.
Replaces "Browse and subscribe to channels".

Co-authored-by: Prakhar Pratyush <prakhar@zulip.com>
2024-05-07 16:51:48 -07:00
Alya Abbott 7fc806ef82 help: Consolidate introduction to topics into one article.
Also create dedicated channels and topics sections in sidebar.

Makes 'start a new topic', a section in introduction to topics
page.

Co-authored-by: Prakhar Pratyush <prakhar@zulip.com>
2024-05-07 16:51:48 -07:00
Mahhheshh 1198785c62 analytics: Improve do_increment_logging_stat performance.
The previous implementation using Django's `get_or_create` for
`do_increment_logging_stat` involved two separate database queries,
potentially leading to race conditions.

Use an `ON CONFLICT ... DO UPDATE` (aka "upsert") query, which
eliminates race conditions and improves performance.  This is mildly
complicated due to the different unique indexes across the various
tables, and the need for bug-for-bug compatibility with the previous
implementation.

Fixes #28947.

Co-authored-by: Alex Vandiver <alexmv@zulip.com>
2024-05-06 16:34:01 -07:00
Dhruv Goyal 178d4f364b documentation: Described display_in_profile_summary field as optional.
Fixes #29908.
2024-05-06 15:32:31 -07:00
Anders Kaseorg f13e94d9ae requirements: Upgrade Python requirements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-05-06 12:56:30 -07:00
Anders Kaseorg 042f28dca8 invites: Broaden invite_expires_in_minutes type.
It may be internally recomputed using .total_seconds() / 60, which is
a float.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-05-06 12:56:30 -07:00
Anders Kaseorg 8b47b5dc34 send_email: Assert custom email payload is a str.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-05-06 12:56:30 -07:00
Anders Kaseorg 0dff5f0a27 narrow: Add maybe_negate annotation needed by mypy 1.10.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-05-06 12:56:30 -07:00
Alex Vandiver b2ebe34500 missedmessage_emails: Backoff the background worker retries. 2024-05-06 12:50:27 -07:00
Prakhar Pratyush 422f5c4e1a help: Rename unarchive_stream management command to unarchive_channel. 2024-05-06 11:18:45 -07:00
Prakhar Pratyush 64c251089d help: Update 'stream' to 'channel' in tab sections. 2024-05-06 11:18:45 -07:00
Mateusz Mandera 87007df8eb webhooks: Rename remaining stream references to channel.
Note: This doesn't change the occurences in the Zapier integration doc,
since they refer to pieces of the UI in Zapier, which may still be using
the "Stream" terminology.
2024-05-06 09:07:57 -07:00
Mateusz Mandera 3c4ab345d0 webhooks: Rename append-stream-name.md->append-channel-name.md. 2024-05-06 09:07:57 -07:00
Mateusz Mandera a119160da3 webhooks: Rename recommended_stream_name->recommended_channel_name. 2024-05-06 09:07:57 -07:00
Mateusz Mandera 1267e10094 webhhoks: Rename stream->channel in bitbucket doc. 2024-05-06 09:07:57 -07:00
Mateusz Mandera 5c9f3cd08c webhooks: Rename create-stream.md to create-channel.md. 2024-05-06 09:07:57 -07:00
Alex Vandiver 3662a6ded9 migrations: Merge 0517 as a no-op.
Migration 0517 migration was already run as 0497 on `main`, but was
accidentally omitted on 8.x until this point.

Merge the 0517 migration into the migration history.  It is included
as a no-op in `main` because it has already run as 0497.
2024-05-06 09:03:02 -07:00
Mateusz Mandera 2b927e355a webhooks: Rename stream->channel in some remaining random places. 2024-05-04 19:01:51 -07:00
Mateusz Mandera 2099afe79b webhooks: Rename stream->channel in function name in clubhouse code. 2024-05-04 19:01:51 -07:00
Mateusz Mandera d7b2655ad2 webhooks: Rename stream_name to channel_name arg. 2024-05-04 19:01:51 -07:00
Mateusz Mandera fef299510f webhooks: Rename assert_stream_message to assert_channel_message. 2024-05-04 19:01:51 -07:00
Mateusz Mandera 4e968869a2 webhooks: Rename api_stream_message to api_channel_message in tests. 2024-05-04 19:01:51 -07:00
Mateusz Mandera dc31347ac4 webhooks: Rename STREAM_NAME to CHANNEL_NAME in tests. 2024-05-04 19:01:51 -07:00
Lauryn Menard 5acd059c38 help-relative-links: Update relative help links for channel rename. 2024-05-03 13:05:57 -07:00
Lauryn Menard d10ad01997 help: Rename and redirect archive-a-stream for channel. 2024-05-03 13:05:57 -07:00
Lauryn Menard c1175f2e55 help: Rename and redirect change-the-privacy-of-a-stream for channel. 2024-05-03 13:05:57 -07:00
Lauryn Menard 500f476de9 help: Rename and redirect change-the-stream-description for channel.
This also contains in-file edits for help/message-retention-policy.md,
help/create-a-channel.md, and help/configure-automated-notices.md.
2024-05-03 13:05:54 -07:00
Lauryn Menard c10c570b89 help: Rename and redirect rename-a-stream for channel. 2024-05-03 13:02:20 -07:00
Lauryn Menard b714bd9eec help: Rename and redirect set-default-streams-for-new-users for channel. 2024-05-03 13:02:20 -07:00
Lauryn Menard fbc66f45ea help: Rename and redirect configure-who-can-invite-to-streams re:channel. 2024-05-03 13:02:20 -07:00
Lauryn Menard c65c2b4a33 help: Rename and redirect configure-who-can-create-streams re:channel. 2024-05-03 13:02:20 -07:00
Lauryn Menard c931966e1b help: Rename and redirect stream-sending-policy for channel. 2024-05-03 13:02:20 -07:00
Lauryn Menard 5342d4ecfb help: Rename and redirect stream-permissions for channel. 2024-05-03 13:02:19 -07:00
Lauryn Menard 95b03ce6e1 help: Rename and redirect manage-user-stream-subscriptions for channel. 2024-05-03 12:55:39 -07:00
Lauryn Menard 859340c914 help: Rename and redirect mute-a-stream for channel. 2024-05-03 12:55:39 -07:00
Lauryn Menard 4908f1c5dc help: Rename and redirect stream-notifications for channel. 2024-05-03 12:55:39 -07:00
Lauryn Menard d97571e1df help: Rename and redirect manage-inactive-streams for channel. 2024-05-03 12:55:39 -07:00
Lauryn Menard 93dd1e9b25 help: Rename and redirect move-content-to-another-stream for channel. 2024-05-03 12:55:39 -07:00
Lauryn Menard 4f97c7b202 help: Rename and redirect change-the-color-of-a-stream for channel. 2024-05-03 12:55:39 -07:00
Lauryn Menard 47ecc4989d help: Rename and redirect pin-a-stream for channel. 2024-05-03 12:55:39 -07:00
Lauryn Menard 696f578c8e help: Rename and redirect add-or-remove-users-from-a-stream for channel. 2024-05-03 12:55:39 -07:00
Lauryn Menard a4c63c5ad0 help: Rename and redirect view-stream-subscribers for channel. 2024-05-03 12:55:39 -07:00
Lauryn Menard 049ce10b6f help: Rename and redirect unsubscribe-from-a-stream for channel. 2024-05-03 12:55:39 -07:00
Lauryn Menard b4e67ee564 help: Rename and redirect browse-and-subscribe-to-streams for channel. 2024-05-03 12:55:39 -07:00
Lauryn Menard 9c353d812e help: Rename and redirect message-a-stream-by-email for channel. 2024-05-03 12:55:39 -07:00
Lauryn Menard bd91c82862 help: Rename and redirect create-a-stream for channel. 2024-05-03 12:55:39 -07:00
Lauryn Menard 14b899eb20 help: Rename and redirect create-streams for channel. 2024-05-03 12:55:39 -07:00
Lauryn Menard 4dbda25e2e help: Rename and redirect streams-and-topics for channel. 2024-05-03 12:55:39 -07:00
Mateusz Mandera eed98edb9d help: Document configuration of SCIM with Microsoft Entra ID. 2024-05-02 18:12:21 -07:00
Tim Abbott 0a756c652c push_notifications: Shard mobile push notifications. 2024-05-02 14:25:10 -07:00
Alex Vandiver 572fbfe114 queue_processors: Pass the worker_num down into the class. 2024-05-02 14:25:10 -07:00
Alex Vandiver 952291e712 migrations: Clean up non one-to-one confirmations/invites.
These models should be one-to-one.  Various bugs in the past have
leaked violations in both directions; we clean them up such that every
PreregistrationUser which is not a multi-use invite has exactly one
Confirmation object associated with it.

Fixes: #22025
2024-05-02 14:23:04 -07:00
Alex Vandiver 594e2823a7 invites: Use transactions more consistently. 2024-05-02 14:23:04 -07:00
Alex Vandiver 9dfaa83aa8 invites: Remove invites worker, make confirmation object in-process.
The "invites" worker exists to do two things -- make a Confirmation
object, and send the outgoing email.  Making the Confirmation object
in a background process from where the PreregistrationUser is created
temporarily leaves the PreregistrationUser in invalid state, and
results in 500's, and the user not immediately seeing the sent
invitation.  That the "invites" worker also wants to create the
Confirmation object means that "resending" an invite invalidates the
URL in the previous email, which can be confusing to the user.

Moving the Confirmation creation to the same transaction solves both
of these issues, and leaves the "invites" worker with nothing to do
but send the email; as such, we remove it entirely, and use the
existing "email_senders" worker to send the invites.  The volume of
invites is small enough that this will not affect other uses of that
worker.

Fixes: #21306
Fixes: #24275
2024-05-02 14:23:04 -07:00
Alex Vandiver 512d53d01a invites: Stop adjusting invited_at on resends. 2024-05-02 14:23:04 -07:00
Alex Vandiver d863aa56de invites: Lock the realm when determining invitation counts.
This prevents users from hammering the invitation endpoint, causing
races, and inviting more users than they should otherwise be allowed
to.

Doing this requires that we not raise InvitationError when we have
partially succeeded; that behaviour is left to the one callsite of
do_invite_users.

Reported by Lakshit Agarwal (@chiekosec).
2024-05-02 14:23:04 -07:00
Alex Vandiver eef5d22944 invites: Make notify_invites_changed transaction-safe. 2024-05-02 14:23:04 -07:00
Alex Vandiver e48d5e4ad2 invites: Split out some functions from zerver.actions.invites.
This will avoid a circular dependency in future commits.
2024-05-02 14:23:04 -07:00
Prakhar Pratyush b17a006bf0 data_import: Remove gitter data import tool.
Gitter broke their older API as part of being integrated
into Matrix.

Their announcement blog says:
"Anything left using the Gitter APIs will need to be
updated to use the Matrix API"

This commit drops the legacy Gitter import tool and
we plan to build a new one for Matrix in future.
2024-05-02 13:25:25 -07:00
Tim Abbott d1921aed26 zulip_updates: Fix typo. 2024-04-30 18:13:18 -07:00
Alya Abbott 89717e767f updates: Add update message (level=3). 2024-04-30 17:53:44 -07:00
Lauryn Menard 8e953d9896 streams-settings-overlay: Update hash for stream to channel rename.
Updates the base hash for the streams setting overlay to be
"channels" instead of "streams".

Because there are Welcome Bot and Notification Bot messages that
would have been sent with the "/#streams" hash, we will need to
support parsing those overlay hashes as an alias for "/#channels"
permanently.

Part of the stream to channels rename project.
2024-04-30 14:44:12 -07:00
Vector73 de90d0acdf message_delete: Update "first_message_id" on message deletion.
We now "first_message_id" of the stream on the deletion of the first
message that was sent to it. This results in 1 extra query when any
stream message is deleted and 3 extra queries when the first message
sent to any stream is deleted.

Fixes #28877.
2024-04-30 14:15:22 -07:00
N-Shar-ma d64d535c2d todo: Require space after colon to separate task title from description.
This fixes the annoying behaviour where a task title with a url in it,
for example, "Fix issue https://github/com/zulip/zulip/issues/1234"
would be wrongly split into a description at the `:` in the url.
2024-04-30 12:36:42 -07:00
Anders Kaseorg d32d4434dd partial: Replace returns plugin with an annotation.
The returns plugin hasn’t been updated for mypy ≥ 1.6.  This
annotation is more limited in that it only supports a fixed number of
positional arguments and no keyword arguments, but is good enough for
our purposes.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-29 17:14:41 -07:00
Anders Kaseorg 87f228fcb0 test_events: Switch verify_action to a context manager API.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-29 17:14:41 -07:00
Anders Kaseorg 9efba89a43 test_invite: Use context manager form of assertRaises.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-29 17:14:41 -07:00
Anders Kaseorg 6fef5c3e46 webhooks: Use partial with positional arguments.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-29 17:14:41 -07:00
Mateusz Mandera 5ff3f0d99a get_presence_dicts_for_rows: Remove dead code for mobile_user_ids.
The argument isn't used for anything anymore.
2024-04-29 17:07:18 -07:00
Mateusz Mandera 217161824f presence: Always run do_update_user_presence in a transaction.
It was already in a transaction in one of the two call points.
2024-04-29 17:07:18 -07:00
Lauryn Menard 62e17c987f exceptions: Add IncompatibleParametersError as a JsonableError.
Creates an IncompatibleParametersError to be used in cases where
there are two (or more) optional parameters for an endpoint that
are incompatible with each other, e.g. there's a parameter for a
user name and a user ID but only one should be sent in the request
to identify the user.

Documents the error on the /api/rest-error-handling article.

Updates the PATCH users/me/subscriptions/muted_topics endpoint to
use this error when both the stream and stream_id parameters are
passed (note this endpoint is currently deprecated).
2024-04-29 16:58:47 -07:00
Sahil Batra 7518d550f2 user_groups: Remove unneeded fields from UserGroup model.
This commit removes name, description, is_system_group and
can_mention_group fields from UserGroup model and rename
them in NamedUserGroup model.

Fixes #29554.
2024-04-26 17:03:09 -07:00
Sahil Batra 27558315a2 settings: Use named_user_group field to access name.
This commit updates code to access name from named_user_group
field which points to the "NamedUserGroup" instead of directly
accessing name from "UserGroup", since name field will only
be present on NamedUserGroup objects in further commits.
2024-04-26 17:03:09 -07:00
Sahil Batra e78d0aacaf tests: Use NamedUserGroup for queries. 2024-04-26 17:03:09 -07:00
Sahil Batra a96c8b8352 groups: Use NamedUserGroup for all queries. 2024-04-26 17:03:09 -07:00
Sahil Batra 8e9c22afdc groups: Move constants inside NamedUserGroup. 2024-04-26 17:03:09 -07:00
Sahil Batra 85b7dbddbc groups: Update subgroup to be NamedUserGroup. 2024-04-26 17:03:09 -07:00
Sahil Batra dfeb896107 mention: Use NamedUserGroup objects in mention code. 2024-04-26 17:03:09 -07:00
Sahil Batra 0ff9aacb96 audit_logs: Set modified_user_group field to NamedUserGroup. 2024-04-26 17:03:09 -07:00
Sahil Batra 6b4f665b36 user_groups: Add migration to copy data to NamedUserGroup table. 2024-04-26 17:03:09 -07:00
Sahil Batra c9a7c13ea7 import: Add code to support import and export of NamedUserGroups. 2024-04-26 17:03:09 -07:00
Sahil Batra b60d5b6fc9 user_groups: Update code in actions module to use NamedUserGroup. 2024-04-26 17:03:09 -07:00
Sahil Batra 86f73fcb3d user_groups: Create NamedUserGroup objects when creating new groups. 2024-04-26 17:03:09 -07:00
Sahil Batra 71b601cf5a groups: Create NamedUserGroup table. 2024-04-26 17:03:09 -07:00
Sahil Batra 75b1f32a19 user_groups: Add get_recursive_strict_subgroups function.
This commit adds get_recursive_strict_subgroups function
which returns all the subgroups but not includes the user
group passed to the function.

We also update the test to check subgroups of named user
groups using the get_recursive_strict_subgroups function.
This is fine as we already test the get_recursive_subgroups
function.
2024-04-26 17:03:09 -07:00
nimishmedatwal ba196cfd6b help: Change URL from all-messages to combined-feed.
Changes url from /help/all-messages to /help/combined-feed.

Also renames files "all-messages.md" and "go-to-all-messages.md"
to "combined-feed.md" and "go-to-combined-feed.md" respectively.

Fixes #27802.
2024-04-26 14:28:13 -07:00
Anders Kaseorg 96fbe060a6 python: Mark regexes as raw strings.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-26 12:30:31 -07:00
Prakhar Pratyush c727b36e9c soft_reactivate: Soft reactivate if group mention has < 12 members.
Earlier, we didn't soft-reactivate users for group mentions
at all because it wasn't easy to calculate group size.

Now, we will soft reactivate if the user group mentions has
less than 12 members.

We don't reactivate all users because a user group can have a
very large size, which can lead to large backlogs in the
deferred-work queue.

Fixes part of #27586.
2024-04-24 17:40:37 -07:00
Prakhar Pratyush 43136abb70 push_notification: Use 'get_mentioned_user_group' function.
This commit updates the code in 'handle_push_notifications'
to use a common lib function 'get_mentioned_user_group'.

The code logically does the same thing in both the places,
hence the change.
2024-04-24 17:40:37 -07:00
Prakhar Pratyush e1ad0e87dd notification_data: Fix incorrect user_group size being used.
Earlier, in 'get_mentioned_user_group_name()' we were using
'get_user_group_direct_member_ids' function which just checks
the number of direct members and not the recursive membership
of the group.

We should instead use 'get_user_group_member_ids' to calculate
the correct members count of the user group.
2024-04-24 17:40:37 -07:00
Alex Vandiver e8e6abdbba management: Add lockfiles to all _once management jobs.
These would be bad if more than once ran at once.
2024-04-24 14:40:28 -07:00
Alex Vandiver 11dd6791c4 management: Provide a common lockfile dir, and a decorator for it.
Factor out the repeated pattern of taking a lock, or immediately
aborting with a message if it cannot be acquired.  The exit code in
that situation is changed to be exit code 1, rather than the successful
0; we are likely missing new work since that process started.

We move the lockfiles to a common directory under `/srv/zulip-locks`
rather than muddy up `/home/zulip/deployments`.
2024-04-24 14:40:28 -07:00
Lauryn Menard 9be4d07442 i18n: Update translated errors for stream to channel rename.
Updates various areas of the backend code that generate
JsonableErrors with translated strings to use channel
instead of stream.

Part of stream to channel rename project.
2024-04-24 14:35:05 -07:00
Lauryn Menard df3ab8deea invites: Update translated errors for stream to channel rename.
In zerver/views/invite.py, updates translated errors strings to
use channel instead of stream.

Part of stream to channel rename project.
2024-04-24 14:35:05 -07:00
Lauryn Menard 9aaddc6231 stream-policy: Update everyone policy for stream to channel rename.
In zerver/models/streams.py, updates translated string for when everyone
can post to a stream/channel to use channel instead of stream.

Part of stream to channel rename project.
2024-04-24 14:35:05 -07:00
Lauryn Menard eb9a142a9e stream-events: Update topic name for stream to channel rename.
In zerver/models/realms.py, updates the topic for stream/channel updates
to be "channel events" instead of "stream events".

Part of stream to channel rename project.
2024-04-24 14:35:05 -07:00
Lauryn Menard 9b46204fad onboarding: Update new org welcome msgs for stream to channel rename.
Updates the translated strings in the messages sent by the welcome
bot in new Zulip organizations to use channel instead of stream.

Comments out part of a test that uses translated Italian strings
to check these welcome bot messages and adds a TODO comment to
note that the test code should be uncommented when those strings
are translated for the stream -> channel rename.

Part of stream to channel rename project.
2024-04-24 14:35:05 -07:00
Lauryn Menard 3f79fd0f10 hotspots: Update "intro_streams" text for stream to channel rename.
Updates the "intro_streams" hotspot translated strings to use
channel instead of stream.

Part of stream to channel rename project.
2024-04-24 14:35:05 -07:00
Lauryn Menard 0b5f325e48 exceptions: Update translated errors for stream to channel rename.
In zerver/lib/exceptions.py, updates translated error strings
to use channel instead of stream.

Note that the STREAM_WILDCARD_MENTION_NOT_ALLOWED and the
STREAM_DOES_NOT_EXIST error codes, and any additional fields
included with those errors, are not changed in these updates.

Part of stream to channel rename project.
2024-04-24 14:35:05 -07:00
Lauryn Menard 51b3ef8ee3 streams-events: Update notifications for stream to channel rename.
Updates notification messages that are sent to "stream events"
topic when a permission or policy setting is changed to use channel
instead of stream. Also, updates some strings that were not marked
for translation in the message that was sent when the retention
policy was changed.

Updates notification messages that are sent when a stream/channel
is created.

Updates notification messages that are sent when a user is
subscribed to stream/channel(s).

Part of stream to channel rename project.
2024-04-24 14:35:05 -07:00
Lauryn Menard 91ffb548cc streams: Update translated errors for stream to channel rename.
Updates translated JsonableError strings that relate to streams
to use channel instead of stream. Separated from other error string
updates as this is a dense area of changes for this rename.

Part of stream to channel rename project.
2024-04-24 14:35:05 -07:00
Lauryn Menard c1f1dc4b25 message-send: Update translated errors for stream to channel rename.
In zerver/actions/message_send.py, updates translated error strings
to use channel instead of stream.

Also, updates the messages sent to bot owners when a stream doesn't
exist or has no subscribers.

Part of stream to channel rename project.
2024-04-24 14:35:05 -07:00
Lauryn Menard acb54a8bc5 emails: Update context/content for stream to channel rename.
In the missed message email, updates "stream_name" context variable
to be "channel_name". This varible is part of some translated
strings in the email's content.

In onboarding zulip topics email, updates content references to
streams to use channels instead for translated strings. Also,
updates "move_topic_to_different_stream_link" context variable to
be "move_channels_link".

Does not yet update the image used in the onboarding topics email
as that will be updated as part of the help center changes for
this rename.

Part of stream to channel rename project.
2024-04-24 14:35:05 -07:00
Lauryn Menard 20f4022391 email-digest: Update translated strings for stream to channel rename.
Updates the translated "New streams" string in the email digest to
instead by "New channels". Also, marks that for translation in the
plain text version of the email.

Updates the generated stream/channel url to use stream_narrow_url
in preparation for updating stream narrow urls for the rename.

Part of stream to channel rename project.
2024-04-24 14:35:05 -07:00
Lauryn Menard abc6f5b8a2 i18n: Update translated string variables for stream to channel rename.
Generally updates variables that appear in translated strings that use
"stream" to instead use "channel".

Two exceptions are ErrorCode.STREAM_DOES_NOT_EXIST JsonableErrors as
changing the variable would also change the fields returned by these
errors to clients.

Changes to context variables in emails and variables in onboarding
welcome bot messages are addressed in separate commits.

Part of stream to channel rename project.
2024-04-24 14:35:05 -07:00
Alex Vandiver 6418d86763 migrations: Switch to AddIndexConcurrently. 2024-04-24 08:56:17 -07:00
Alya Abbott 363ea09710 help: Change "Via compose box buttons" tab label to use the singular. 2024-04-23 09:57:27 -07:00
Sayam Samal 19a7dae8aa docs: Update the gear menu icon.
This commit updates the /help and /api docs to reflect the new gear
menu icon introduced in bc3d486.
2024-04-23 09:24:02 -07:00
Lauryn Menard b45c5a30c8 api-docs: Update API feature level 249 documentation.
Updates the API changelog entry and changes notes for feature level
249 to match other API updates to narrow filters, and links to the
help center article on emoji reactions in these notes.

Feature level 249 changes were originally in commit c3408b56f0.
2024-04-22 09:27:39 -07:00
Kenneth Rodrigues 081119f461 push-notifications: Migrate to typed endpoint. 2024-04-21 11:09:32 -07:00
Kenneth Rodrigues d03659ee1c read-receipts: Migrate to typed endpoint. 2024-04-21 11:09:32 -07:00
Kenneth Rodrigues 6704faf3cd reactions: Migrate to typed_endpoint. 2024-04-21 11:09:32 -07:00
Lauryn Menard c0be6c6b98 api-docs: Clean up feature level 233 and 230 documentation.
Updates the API changelog entries and changes notes for feature
levels 233 and 230, which both are related to the onboarding
steps (hotspots and one-time notices) updates.

Feature level 233 was originally documented in commit 83bd9955e3
and ac8af3d6de.

Feature level 230 was originally documented in commit 8d633cc36.
2024-04-21 11:07:18 -07:00
Lauryn Menard 02e98f7fa2 api-docs: Tweak newly documented invites endpoints documentation.
Makes a few small tweaks on the newly documented invites endpoints
for current API documentation conventions that were missed in the
review process.
2024-04-21 11:04:35 -07:00
Lauryn Menard cc5b846410 api-docs: Make small clean-ups to feature level 254 updates.
Updates the changelog entry to use "ID" instead of "id".

Revises text for "null" value to match other field descriptions
in these stream/subscription objects.
2024-04-21 11:03:39 -07:00
tnmkr 5128d8f9af streams: Add creator field.
Adds nullable creator field, containing a reference to the user who
created the stream. When creating a stream, acting user is set as
the creator of the stream. Since API calls to create streams always
have an acting user, this field should always be set when streams
are created using the API.

Because streams can be created with no acting user, this field is
nullable. We try to backfill existing streams using RealmAuditLog table,
but not all streams are guaranteed to have a recorded create log. Thus
this new field is left null when it cannot be backfilled. We also set
this field to null when the creator user is deleted.
2024-04-20 19:03:43 -07:00
Tim Abbott 9fa7f71125 import_realm: Include UserProfile in early update_model_ids. 2024-04-20 19:03:43 -07:00
Vector73 0f97733687 api_documentation: Document "/invites/{prereg_id}" endpoint. 2024-04-20 18:12:04 -07:00
Kenneth Rodrigues 5db24e002c narrow-parameter: Add validation for the narrow parameters. 2024-04-20 09:04:26 -07:00
Kenneth Rodrigues def2d402f4 message-flags: Migrate message flag endpoints to typed_endpoint. 2024-04-20 09:04:26 -07:00