Commit Graph

13450 Commits

Author SHA1 Message Date
Alex Vandiver 670c7e7ba4 settings: Remove now-unnecessary EMAIL_DELIVERER_DISABLED setting. 2021-05-18 12:39:28 -07:00
Alex Vandiver 1e67e0f218 deliver_scheduled_*: SELECT FOR UPDATE the relevant rows.
`deliver_scheduled_emails` and `deliver_scheduled_messages` use their
respective tables like a queue, but do not have guarantees that there
was only one consumer (besides the EMAIL_DELIVERER_DISABLED setting),
and could send duplicate messages if multiple consumers raced in
reading rows.

Use database locking to ensure that the database only feeds a given
ScheduledMessage or ScheduledEmail row to a single consumer.  A second
consumer, if it exists, will block until the first consumer commits
the transaction.
2021-05-18 12:39:28 -07:00
Alex Vandiver 82797dd53c settings: Standardize the name of the deliver_scheduled_messages logs.
This makes it match its command name, and other logfile name.
2021-05-18 12:39:28 -07:00
Vishnu KS e019045abe actions: Create send_message_to_signup_notification_stream. 2021-05-14 15:10:02 -07:00
Anders Kaseorg e015f3ed7d docs: Correct “webapp” to “web app”.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-05-14 13:15:38 -07:00
Tim Abbott 73123300e3 models: Improve documentation for UserMessage. 2021-05-14 10:48:00 -07:00
Tim Abbott 6e9683fe6f test_compatibility: Mock desktop minimum versions.
This fixes the tests failing since
454eced466, in a way that won't require
us to change these tests for future version bumps.
2021-05-13 13:03:42 -07:00
Anders Kaseorg 668b5137b0 version: Display Zulip version in About Zulip dialog.
We record Git details about the merge-base with upstream branches in
the zulip-git-version file, if the upstream repository is available.

Note that the first Git upgrade after merging the parent commit will
not include the merge-base details, since the upstream repository will
not have been available.

Co-authored-by: Tim Abbott <tabbott@zulip.com>
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-05-13 11:36:12 -07:00
Tim Abbott b829b95108 email_mirror: Remove unnecessary EMAIL_GATEWAY_PATTERN logging.
These logs were pretty spammy, and there have long been much better
ways to communicate to system administrators that the incoming email
gateway is great, including, most importantly, in the section of the
emails themselves that explains how replying works.
2021-05-13 11:17:01 -07:00
sahil839 213eda1f32 message: Check stream_post_policy when moving messages between streams.
Previously only admins were allowed to move messages between streams
and admins are allowed to post in any stream irresepctive of stream
post policy, so there was no need to check for stream post policy.

But as we now allow other members to also move messages, we need
to check whether the user who is moving the message is allowed
to post to the target stream (i.e. stream to which the messages
are being moved) and thus we allow moving messages only if the
user is allowed to post in target stream.
2021-05-13 08:42:24 -07:00
Mateusz Mandera f1cf9f740d tests: Add test for bulk_access_messages scenarios in message moving. 2021-05-13 08:42:24 -07:00
sahil839 b52ad3e536 message_edit: Allow moving message to stream based on setting value.
We allow the users to move message between streams according to the
value of 'move_messages_between_streams_policy'.
2021-05-13 08:40:57 -07:00
Mateusz Mandera de6bd22ee9 outgoing_webhook: Treat "" json in response as response_not_required.
b7b1ec0aeb made our checks of the response
format stronger, to enforce that the json translates to a valid dict.
However, old client code (zulip_botserver) was using "" as equivalent to
response_not_required - so we need to keep backward-compatibility to not
break things built on it.
2021-05-13 08:07:38 -07:00
Tim Abbott 41d499d44c message_edit: Require access to messages to move between streams.
Currently, moving messages between streams is an action limited to
organization administrators. A big part of the motivation for that
restriction was to prevent users from moving messages from a private
stream without shared history as a way to access messages they should
not have access to.

Organization administrators can already just make the stream have
shared history if they want to access its messages, but allowing
non-administrators to move messages between would have
introduced a security bug without this change.
2021-05-12 16:23:22 -07:00
Tim Abbott 0bfef96543 bulk_access_messages: Bulk fetch Subscription details.
This completes the effort to make it possible to use
bulk_access_message in contexts where there are more than a handful of
messages without creating performance issues.
2021-05-12 16:23:22 -07:00
Tim Abbott c6e1702335 bulk_access_messages: Support passing in a stream for all messages.
This lets us avoid fetching the Stream in a loop.
2021-05-12 16:23:22 -07:00
Tim Abbott 4a8dcf14ef bulk_access_messages: Use a bulk UserMessage query.
This removes one of the three queries that runs in a loop with this
bulk access function.
2021-05-12 16:23:22 -07:00
Tim Abbott ee780e1f08 message: Test queries used by bulk_access_messages. 2021-05-12 16:23:22 -07:00
Tim Abbott c84ea01869 message: Refactor has_message_access parameters. 2021-05-12 16:23:22 -07:00
Tim Abbott 7ef0d21fc2 message_edit: Pass old_stream to update_messages_for_topic_edit.
We'll need this for checking access to moved messages.
2021-05-12 16:23:22 -07:00
Tim Abbott f78e604868 message_edit: Pass acting_user to update_messages_for_topic_edit.
We'll need for checking access if non-administrators can move topics.
2021-05-12 16:23:22 -07:00
Gaurav Pandey dada7bb4bb tests: Clean up tests for realm_domain and update_streams endpoint.
Cleaning up test_realm_domains.RealmDomainTest.test_list_realm_domains,
test_subs.StreamAdminTest.test_private_stream_live_updates,
test_subs.StreamAdminTest.test_realm_admin_can_update_unsub_private_stream
and test_subs.StreamAdminTest.test_non_admin_cannot_access_unsub_private_stream.
2021-05-12 12:38:16 -07:00
Steve Howell a518cea65d performance: Use values_list for message edits. 2021-05-12 10:52:09 -07:00
Vishnu KS bbcf396303 tests: Create assertNotInHomePage helper function. 2021-05-12 10:34:12 -07:00
Vishnu KS 75a3059b57 tests: Create assertInHomePage helper function. 2021-05-12 10:34:12 -07:00
Tim Abbott 06f1ea657e navbar: Adjust label for usage statistics. 2021-05-12 10:34:12 -07:00
Vishnu KS 051dab58ea navbar: Add gear menu advertisement for sponsoring zulip. 2021-05-12 10:21:48 -07:00
Steve Howell b4470ac8e1 performance: Add get_subscriptions_for_send_message.
This new function optimizes how we fetch subscriptions
for streams.  Basically, it excludes most long-term-idle
users from the query.

With 8k users, of which all but 400 are long term idle,
this speeds up get_recipient_info from about 150ms
to 50ms.

Overall this change appears to save a factor of 2-3 in the backend
processing time for sending or editing a message in large, public
streams in chat.zulip.org (at 18K users today).
2021-05-12 08:10:57 -07:00
Tim Abbott b15941610d message: Support avoiding database queries in has_message_access.
If the caller has already fetched the Stream or subscription details
for the user, those can be passed to has_message_access to avoid extra
database queries.
2021-05-11 20:46:49 -07:00
Tim Abbott 44fddcc9c1 message: Reorder checks in has_message_access.
This refactor makes this function easier to read and understand.
2021-05-11 20:46:49 -07:00
Alex Vandiver 237efdee6c send_email: Show more information about messages which failed to send. 2021-05-11 14:27:45 -10:00
Mateusz Mandera c95cac2dd7 outgoing_webhook: Send response payload to bot owner if it was invalid.
When the format of the response received from the outgoing webhook
server is invalid (unparsable json, or just wrong format that doesn't
translate into a dictionary etc.), a message with the error is sent to
the bot owner. We should include the actual payload to make reasonable
debugging possible.

In notify_bot_owner we have to move the `if response_content` block to
append the payload to the message whenever it was specified as an
argument to the function. It shouldn't be nested inside
`elif status_code` as before.
2021-05-11 14:27:00 -07:00
Alex Vandiver 0f1611286d management: Rename the deliver_email command to deliver_scheduled_email.
This makes it parallel with deliver_scheduled_messages, and clarifies
that it is not used for simply sending outgoing emails (e.g. the
`email_senders` queue).

This also renames the supervisor job to match.
2021-05-11 13:07:29 -07:00
Steve Howell 1e63282cc2 tests: Test email/push more thoroughly for idle users. 2021-05-11 14:33:12 +00:00
Steve Howell 3161b5d892 tests: Simplify test_user_message_filter. 2021-05-11 13:53:55 +00:00
PIG208 d8db797798 doc: Fix configurations for images in the doc of newrelic.
The screenshot generating mechanism doesn't work for newrelic and
causes error because its configuration file doesn't exist. This
commit fixes the configuration and re-generate the screenshots.
2021-05-10 17:50:32 -07:00
Abhijeet Prasad Bodas 67cd385cec mute user: Add user documentation page.
Also link to it from the API documentation page,
other help pages, and the confirmation dialog for
muting a user.

With substantial edits by tabbott and alya.
2021-05-10 17:10:40 -07:00
Mateusz Mandera 20f99f429d actions: Extract get_active_bots_owned_by_user function. 2021-05-10 15:38:24 -07:00
Mateusz Mandera 8261f7e801 commands: Add delete_user management command and document it. 2021-05-10 15:38:14 -07:00
Ganesh Pawar 529f72fa3f markdown: Add support for sms and tel links.
Fixes #18390
2021-05-10 15:15:34 -07:00
Mateusz Mandera 6b056ca332 retention: Change default behavior of restore_messages command to noop.
Having "restore everything" as the default is a very bad idea. An
argument should explicitly be given for that behavior.
2021-05-10 15:13:10 -07:00
Dinesh 7413966255 tests: Remove duplicate verify_backend() calls. 2021-05-10 13:56:06 -07:00
Alex Vandiver 27012e343b edit_linkifiers: Show the right command name in help text. 2021-05-10 13:51:22 -07:00
Siddharth Asthana 8f864c5107 commands: Add change_realm_subdomain management command.
Add command to change realm's subdomain. This command takes two
arguments, realm's string_id and new subdomain name.
2021-05-10 12:30:58 -07:00
Tim Abbott 2c01354569 management: Use required kwargs in add_realm_args.
This makes management commands more readable, since one doesn't need
to know details of how the library works to read based code.
2021-05-10 12:30:58 -07:00
akshatdalton 55f4996f16 markdown: Fix silent wildcard mentions bug.
A message containing wildcard mention when quoted (which
is turned into a silent mention) or message with silent
wildcard mention notifies the users by sending desktop,
sound, and missed message email notifications. This
is clearly a bug which is fixed by this commit.

Fixes: #18354.
2021-05-10 12:19:40 -07:00
Tim Abbott 70244896e5 test_subs: Remove now invalid JSON encoding of parameters.
All of these were missed in the previous commit.
2021-05-10 10:42:11 -07:00
Gaurav Pandey 96e035a2f0 api: Fix encoding of strings in streams endpoint.
* Remove unnecessary json_validator for string parameters.
* Update frontend to pass right parameter.

Bump api feature level and highlight the fix for `emojiset`
parameter of `settings/display` endpoint in zulip.yaml file.

Fixes part of #18035.
2021-05-10 10:29:22 -07:00
Gaurav Pandey 9abe1cafbe api: Fix encoding of strings in display settings endpoint.
* Remove unnecessary json validator for string validator.
* Update frontend to pass right validator.
* Update zulip.yaml to pass right parameter for curl request
  in openapi.
* Update python_examples to pass right paramater.

Fixes part of #18035.
2021-05-10 10:03:32 -07:00
Anders Kaseorg 544bbd5398 docs: Fix capitalization mistakes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-05-10 09:57:26 -07:00