Commit Graph

42965 Commits

Author SHA1 Message Date
Suyash Vardhan Mathur 2359ddd402 curl_examples: Refactor testing code.
This commit refactors the code to find the
lines to be first, and then test all the
lines that contained commands.

This was done to avoid duplication of
the code for the other case, where the
.md file won't exist, as those are soon
to be deleted in favour of a common template.
2021-06-04 09:43:24 -07:00
Suyash Vardhan Mathur 64df949f7a curl_examples: Use endpoint list from rest-endpoints.
Soon, the .md files of each endpoint would
be removed and be auto-generated from OpenAPI
data.
So, instead of using the files directly,
we should check from the list of endpoints and
open the files from there.

A follow-up to change logic when the .md files
get deleted should be done.
2021-06-04 09:43:24 -07:00
Tim Abbott bb83aab860 docs: Correct widgets doc discussion of slash commands. 2021-06-04 09:23:51 -07:00
Tim Abbott 20c629f327 compose: Clarify title for wide reply button.
This changes the button text from "Reply" to "Reply to selected
message". Here's the thinking:

* The title "Reply" was a little confusing/inconsistent with the
  button's label.

* If you're hovering over the button, it's because you want more
  information about what it does -- not just a repeat of the button's
  label.

* The "Message foo > bar" content of the button already cleanly
  expresses what the button will do if you click it right now.

* The hover text "Reply to selected message (r)" explains to you what
  that button's role is in all situation, not just with the current
  selection, and thus documents the concept.  And it also gives you
  clarify if you're thinking "but how do I reply to something in
  Zulip?" and try hovering over the buttons at the bottom to find out.
2021-06-04 09:18:59 -07:00
Abhijeet Prasad Bodas 86d6872a80 onboarding: Select Message FOR UPDATE when adding reaction.
Although race conditions are super-unlikely for these onboarding
messages, it's better to write correct code since it might be copied.
2021-06-04 08:18:17 -07:00
Abhijeet Prasad Bodas 90b6fa7881 reactions: Select Message FOR UPDATE when adding/removing.
This locks the message row while a reaction is being added/removed,
which will handle race conditions caused by deleting the message
at the same time.

We make sure that events work happens outside the transaction,
so that in case there's some problem with the queue processor, the
locks aren't held for too long.

As a nice side-effect, we also handle race conditions from double
adding reactions, because once the message is locked, a duplicate
request will wait till the earlier transaction commits, and hence
will not throw `IntegrityErrors`s (rather, will be handled in our
safety check in the /views code itself), which earlier had to be
handled explicitly.
2021-06-04 08:18:17 -07:00
Abhijeet Prasad Bodas efc2f49e3c submessage: Select Message FOR UPDATE when creating.
This locks the message while creating a submessage, which
will handle race conditions caused by deleting the message
simultaneously.

We make sure that events work happens outside the transaction,
so that in case there's a problem with the queue processor,
the locks aren't held for too long.
2021-06-04 08:18:17 -07:00
Abhijeet Prasad Bodas 5f4113cf60 message delete: Select Message FOR UPDATE when archiving.
Further commits will start locking the message rows while
adding related fields like reactions or submessages,
to handle races caused by deleting the message itself at the
same time.

The message locking implemented then will create a possibility
of deadlocks, where the related field transaction holds a lock
on the message row, and the message-delete transaction holds a
lock on the database row of the related field (which will also
need to be deleted when the message is deleted), and both
transactions wait for each other.

To prevent such a deadlock, we lock the message itself while
it is being deleted, so that the message-delete transaction
will have to wait till the other transaction (which is about
to delete the related field, and also holds a lock on the
message row) commits.

https://chat.zulip.org/#narrow/near/1185943 has more details.
2021-06-04 08:18:17 -07:00
Abhijeet Prasad Bodas 1a9f385e17 access_message: Allow selecting message row FOR UPDATE.
This is a prep change to start using `SELECT FOR UPDATE` queries
when there is a chance of race conditions.
2021-06-04 08:18:16 -07:00
Abhijeet Prasad Bodas 51f5bbcd57 test_events: Run on_commit send_event hooks immediately.
Further commits will hook some `send_event` calls to `on_commit`.
With those changes, these will never be executed in tests, because
transactions never get commited with `TestCase`, which the
`ZulipTestCase` is a subclass of.

We want to make sure that these events are actually sent for testing
purposes, hence this change.

There's no need to actually capture the callbacks, because the
events are already thoroughly tested.
2021-06-04 18:12:39 +05:30
Abhijeet Prasad Bodas 60464a4cea tests: Run on_commit hooks immediately in tornado_redirected_to_list.
Further commits will hook `send_event` calls to `on_commit`
in some cases. This change will make it easier to test such
situations.

We don't need to actually capture the callbacks, because the
events sent are already tested via the list in which they are
captured by `tornado_redirected_to_list`.
2021-06-04 18:12:39 +05:30
Abhijeet Prasad Bodas 8b14704d35 test_classes: Fix misplaced `tornado_redirected_to_list` comment. 2021-06-04 18:12:21 +05:30
Tim Abbott b920929182 lint: Fix line-wrapping for a recently merged test change. 2021-06-03 18:52:39 -07:00
sahil839 cbb508fa23 help: Update invite docs to accomodate the UI change.
This commit updates the docs as the setting for invites
is separated into two UI elements - a checkbox for
'are invites required to join organization' and a
dropdown for setting 'who can invite new users'.
2021-06-03 18:45:29 -07:00
sahil839 d8c4b96b12 setting: Divide user_invite_restriction into a checkbox and dropdown.
This commit divides the user_invite_restriction setting dropdown to
a checkbox and a dropdown.
The checkbox is used for 'realm_invite_required' setting and dropdown
for 'realm_invite_to_realm_policy'.

This separation of UI elements is fine as these two settings are
separate in database also and also helps in removing excess if-else
conditions and switch cases.
2021-06-03 18:45:29 -07:00
sahil839 8846df6b53 node_tests: Deduplicate test_sync_realm_settings in settings_org tests.
There was a lot of duplicate code in test_sync_realm_settings where
each value in common_policy_values was being tested for different
policies (create_stream_policy and invite_to_stream_policy).

This commit deduplicates is by using a for-loop for testing all
common_policy values and extracting the code as a function to test
different policies.
2021-06-03 18:45:29 -07:00
sahil839 a271308ac3 admin: Avoid passing unnecessary policy values to admin_tab.hbs.
We do not require values of realm_create_stream_policy,
realm_invite_to_stream_policy, realm_private_message_policy
and realm_wildcard_mention_policy in the organization settings
templates, as we handle the dropdown values of these settings
in javascript code (settings_org.js) only and these values
are not used anywhere in templates.
2021-06-03 18:45:29 -07:00
sahil839 c09e3fd845 settings_users: Directly use role value in sort_role.
There is no need to write a custom function for sorting
the users table by role since role values are according
to hierarchy of roles already.
2021-06-03 18:45:28 -07:00
sahil839 10e9789179 message_edit: Show save button correctly in message edit form.
Previously the logic to show save button considered only topic
and content edit. This commit fixes it to show the save button
when only stream edit is possible and content and topic edits
are not.

This commit only introduces a simple fix, in long-term we would
want to change the logic of get_editability to include stream
edits as well but it would also require discussion on when to
show the edit icons at different places, so it is better to do
it in a separate commit later.
2021-06-03 17:58:43 -07:00
sahil839 7c7e81e662 message_edit: Rename show_edit_stream to is_stream_editable.
This commit renames show_edit_stream to is_stream_editable
for more clarity.
2021-06-03 17:58:19 -07:00
sahil839 bf9c17e8a8 message: Fix moving messages between streams for non-admins.
This commit fixes a bug where moving messages between streams was
not allowed for non-admins when allow_community_topic_editing was
set to false and move_messages_between_streams_policy was set to
Realm.POLICY_MEMBERS_ONLY.

The bug is fixed by calling can_edit_content_or_topic only when
topic or content edit is there and not in the case where only
message is moved from one stream to another.
2021-06-03 17:53:59 -07:00
sahil839 db294cb386 message: Extract logic to check message edit permissions in a function.
This commit extracts the logic of checking the message edit permissions,
like whether the sender is same as user, whether it is a (no topic)
message or whether community topic editing is allowed, into a separate
function.

This is a prep commit for fixing a bug where permission to move messages
between streams is affected by permission of editing topics.
2021-06-03 17:53:55 -07:00
sahil839 6be232aa42 message_edit: Check 'topic_name is not None' and not 'content is None'.
Previously when enforcing the check to do not allow editing topics
after a certain time, we were checking whether 'content is None' and
considering it as that if content is None then there must be topic
edit.

But after adding support for moving messages between streams it can be
the case that we are neither changing topic nor content and just moving
streams, and the original code raises error if this is done after the
time limit of editing topics, which is wrong.

This commit fixes this by actually checking 'topic_name is not None'.
2021-06-03 17:13:32 -07:00
sahil839 e2835d3f4f message_edit: Modify the error message for topic edit deadline.
This commit modifies the error message shown when topic edit
deadline is passed to make it more clear that the limit is for
editing message's topic.
2021-06-03 17:13:32 -07:00
sahil839 f827debe9d settings: Move move-message-between-stream setting to "Message Editing".
This commit moves "Who can move messages between streams" setting to
"Message Editing" section.
2021-06-03 17:13:32 -07:00
sahil839 4d20bce6e4 settings: Move message edit settings to "Organization Permissions".
The message-editing section of settings is moved from "Organization
Settings" to "Organization Permissions", which feels like a more
natural place for these settings.
2021-06-03 17:13:32 -07:00
m-e-l-u-h-a-n fa34f793a7 recent topics: Display other sender names in tooltip.
It is a follow up for #18451.
2021-06-03 14:55:40 -07:00
Tim Abbott 746d3e8dcb presence: Disable 'Idle' for users with idle status.
Previously, we oddly displayed "Last active: Just now" for users in
this situation, which doesn't make any sense.
2021-06-03 14:53:21 -07:00
Tim Abbott 16bd6e6b1d presence: Use consistent logic for displaying last active time.
Previously, we had this complicated layering where the right sidebar
logic would display "Last active: foo" but the user popovers would
just display "foo", which doens't make any sense, since the two
settings have equal context about the string.

We deduplicate that and also arrange that the "Last active:" prefix is
used when it's not clear what we're talking about; i.e. all the values
except for "Active now".
2021-06-03 14:53:21 -07:00
Priyank Patel 75034bb767 settings_orgs: Add hover like effects on focus for save-discard buttons.
This uses the same effect as hovering over the button when they are
focused using keyboard shortcuts such as Tab or Alt + Tab.
2021-06-03 12:41:10 -07:00
Priyank Patel 2441138a7b settings_orgs: Use button element for save-discard button.
There is no clear reason to not use a button element here. According
to the spec pharasing content, which includes the <span> element,
are allowed in the button element.

Manually tested both buttons to make sure it works and made sure all
the selectors are updated by grepping all the selector classes/id in
the handlebars templates that are parents of the button or are
present on the button.

(One of the jQuery handler code got reformatted due to it fitting
the line limit due to one character deletion for the selector)
2021-06-03 12:41:10 -07:00
Priyank Patel cee94654df minor: Use Array.includes instead of a regex to check for values. 2021-06-03 12:41:10 -07:00
Suyash Vardhan Mathur 94a22f9323 apidocs: Modify tests to reflect new templates.
Soon, each endpoint won't necessarily have a .md
file, but would generate API doc directly from
OpenAPI data using a template.

So, the lists of endpoints to be tested should not
be taken from the .md files, but from the REST
endpoints available in the sidebar.

This commit also adds a missing test for an invalid
article being accessed in the URL of an API page.
2021-06-03 10:52:22 -07:00
Suyash Vardhan Mathur d1ccf15cd3 apidocs: Fix invalid API page bug.
The current logic to get API pages' title using
OperationID should be used when the first line
of the file explicitly mentions so.

In cases where the files didn't begin with `#` but also
didn't need to get title from OpenAPI summary,
this logic fails and causes Server error.
This particularly happens when the article is invalid,
and the `missing.md` file doesn't need title to be
generated, but doesn't start with `#` either.

This commit fixes the logic of using the generated title and covers the bug.
2021-06-03 10:47:47 -07:00
Vishnu KS 5db53029a5 api: Include is_billing_admin as an attribute in user response.
This is sufficiently useful that it should be made available to clients.
2021-06-03 10:27:07 -07:00
Vishnu KS 3d5ee69b21 stripe: Create make_user_billing_admin helper function. 2021-06-03 10:13:59 -07:00
Wesley Aptekar-Cassels d5ba94082a markdown: Increase max rendered message length to 1MB.
This should help with #17425, where messages with lots of LaTeX are
lost, due to the large expansion factor.

This isn't a total fix for this - large messages with lots of LaTeX
can still end up larger than 1MB, and rendering could timeout, but
this fix should help significantly.

1MB is still small enough that I don't expect we'll run into any DOS
problems - my testing didn't show any problems rendering messages that
contain ~1MB of LaTeX.
2021-06-03 10:10:35 -07:00
seiwailai b584790541 validator: Add generic check_or.
Fixes part of #17914. Added generic check_or function and tests.
2021-06-03 09:49:50 -07:00
Alex Vandiver 4525543ec6 delete_realm: Disallow deletion of realms we've had billing plans with. 2021-06-03 09:38:12 -07:00
Mateusz Mandera 01818c1825 docs: Add additional missing detail to the oneclick app release doc. 2021-06-03 09:35:34 -07:00
Mateusz Mandera 1fdf09cfac docs: Update link to image check script in digitalocean tools repo.
The old link doesn't work, the script was moved to
https://raw.githubusercontent.com/digitalocean/marketplace-partners/master/scripts/99-img-check.sh
2021-06-03 09:35:34 -07:00
Mateusz Mandera 67dada8a44 corporate: Add some basic documentation of the corporate/* models.
The billing system has been mostly devoid of any documentation. This
commit is meant to add a basic documentation of the data model of this
system.
2021-06-03 09:31:21 -07:00
akshatdalton 7df62ebbaf settings: Make `MAX_MESSAGE_LENGTH` a server-level setting.
This will offer users who are self-hosting to adjust
this value. Moreover, this will help to reduce the
overall time taken to test `test_markdown.py` (since
this can be now overridden with `override_settings`
Django decorator).

This is done as a prep commit for #18641.
2021-06-03 09:26:28 -07:00
Vishnu KS 9b9d30152a tests: Replace incorrect asserts with assert.equal. 2021-06-03 09:24:38 -07:00
Riken Shah 7ae5e7287b puppeteer_test: Add `wait_for_modal_to_close` method to `CommonUtils`.
This commit adds the `wait_for_modal_to_close` method
and replaces all the instances where we are using jQuery
to check if the modal is closed.
2021-06-03 09:23:54 -07:00
akshatdalton 0f3d45f078 settings: Use `user-plus` icon instead `plus-circle` icon for invites.
To show invite user icon, we use `user-plus` icon.
2021-06-02 20:40:54 -07:00
akshatdalton b98ad46459 templates: Move edit_bot to settings/.
Since templates for settings UI should be
in `static/templates/settings`.
2021-06-02 20:36:21 -07:00
akshatdalton d48a728fd0 templates: Move bot_avatar_row to settings/.
Since templates for settings UI should be
in `static/templates/settings`.
2021-06-02 20:36:21 -07:00
akshatdalton 55d3090f05 templates: Move uploaded_files_list to settings/.
Since templates for settings UI should be
in `static/templates/settings`.
2021-06-02 20:36:21 -07:00
Robert Imschweiler 31322be598 css: Make login-social-button responsive to larger fonts. 2021-06-02 20:23:33 -07:00