Commit Graph

42003 Commits

Author SHA1 Message Date
Anders Kaseorg bf447a726f test-documentation: Clean up fixed HTML validation ignore patterns.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-30 15:49:30 -07:00
Greg Price da8763d889 tools: Avoid `readlink -f` in *-pull-request scripts.
This is a feature of GNU readlink that isn't in the BSD readlink
found on macOS.

For using this and other GNU coreutils features in our scripts in
general, we could use a solution like mobile's tools/lib/ensure-coreutils.sh
to get GNU coreutils on the PATH -- check if it's there already,
if not then try to find a Homebrew install of it and use that, if not
then print a helpful message.

But even then there'd be a bootstrapping problem of how to find
ensure-coreutils.sh .  That involves exactly the same problem as we
have for finding git-tools.sh in these lines.  So in fact in mobile
for the task of finding ensure-coreutils.sh in the first place, we
do without `readlink -f` anyway.

The one consequence of this behavior-wise is that if you make a
symlink somewhere that points directly at that script (say in your
`~/bin/`), and try to run it using that symlink, it won't work.
(It'll still work just fine if there are symlinks somewhere higher
up in the paths involved -- just not for the script itself.)
An ideal CLI program really should support that, I think, but
lacking a better idea, this seems an acceptable compromise.
2021-04-30 14:57:13 -07:00
Alex Vandiver fd1774dcba push_notifications: Give full stack information on an exception.
This error has been seen in production instances, but we need more
context to be able to determine what might be causing it.
2021-04-30 14:03:52 -07:00
Wesley Aptekar-Cassels 6b7a3fb74a markdown: Rewrite all external images to use Camo.
Requesting external images is a privacy risk, so route all external
images through Camo.

Tweaked by tabbott for better test coverage, more comments, and to fix
bugs.
2021-04-30 10:36:16 -07:00
Ganesh Pawar ddf2127035 widgets: Prevent edits to widgets.
As of now, editing a widget doesn't update the rendered content.
It's important to ensure that existing votes or options added later on
don't get deleted when rendered.
This seems more complex than it's worth.

For now, we just prevent edits to widgets.
This commit makes the UI clearer that editing widgets isn't allowed.

See also:
https://github.com/zulip/zulip/issues/14229
https://github.com/zulip/zulip/issues/14799

Fixes #17156
2021-04-30 09:55:25 -07:00
Nikhil Maske 04da50a7bb user docs: Move "Create a poll" section in Sending messages.
Fixes #18312.
2021-04-30 09:37:48 -07:00
Vishnu KS 7f3fc3423b audit log: Create audit log when a realm is created.
This is mainly useful in recording the user who created the realm,
when possible.
2021-04-30 09:25:11 -07:00
Nikhil Maske 0023f7f9a0 settings css: Make HTML table headers sticky.
Introduce a new class "table-sticky-headers" in the settings
and organisation settings HTML table tags and it is used
to make the table headers fix at the top. This commit also
add the background-color and hover properties to the
settings and organisation settings table to make them look
similar to the recent_topics_table.
2021-04-30 08:19:47 -07:00
Aman Agrawal 5adc6d7297 compose_control_buttons: Use data-tippy-content instead of title.
We don't want browser default titles and tooltips to overlap,
so we remove titles here.
2021-04-30 07:52:32 -07:00
Riken Shah 456793bec2 puppeteer_test: Add missing `wait_for_checked` call to avoid rare flake.
This commit fixes a rare flake which was most probably
caused when we clicked on the `Check All` button, and
we instantly cleared the filter when it was still marking
the user `checked`, which nullified the effect of clicking
on `Check All` button.
2021-04-30 07:51:48 -07:00
Ganesh Pawar 830f1fa8c5 upload: Refactor and add tests for ensure_avatar_image in upload.py.
`ensure_basic_avatar_image` and `ensure_medium_avatar_image` are
essentially the same thing, except a size parameter.
So, refactor them into a single function.

This doesn't introduce any functional changes.
2021-04-29 21:18:13 -07:00
tushar912 c6671a67dd tools: Add tools/build-docs --clean option.
Currently the tools/build-docs was slow
because the clean option was rebulding everything.
But this is only required if one wants the left
sidebar to update.

So now set the default to exclude clean and
add clean option only if --clean is passed.

Also a warning is displayed if clean option is
not passed that the left sidebar won't update.

Fixes #17961.
2021-04-29 21:01:28 -07:00
tushar912 94afc72764 docs: Rewrite tools/build-docs in python.
Change the script to python. This is done
for the following reasons.
* It enables us to use the sanity_check.
* Later when we add warning to include
--clean flag we can use the pre-existing
WARNING from zulip_tools rather than using
terminal color codes.

TODO: Currently this script is slow as the
clean option is expensive so instead use only
html by default and clean only if --clean
option is passed.

Part of #17961.
2021-04-29 21:01:14 -07:00
Nikhil Maske a1d0fa5cbb confirm_dialog: Change copy in several dialogs.
Based on feedback from @alya in #17947.
2021-04-29 20:43:04 -07:00
Tim Abbott 615ad2d5d8 middleware: Simplify logic for parsing user-agent.
This avoids calling parse_user_agent twice when dealing with official
Zulip clients, and also makes the logical flow hopefully easier to read.

We move get_client_name out of decorator.py, since it no longer
belongs there, and give it a nicer name.
2021-04-29 17:47:41 -07:00
Tim Abbott 3cf0156997 context_processors: Remove unnecessary get_client_name call.
This detail is now being managed by our middleware.
2021-04-29 17:47:32 -07:00
orientor fe260fb892 middleware: Show client version in logging if available.
Fixes #14067.
2021-04-29 17:07:37 -07:00
orientor ac203cd9f1 middleware: Add client_version attribute to request. 2021-04-29 17:03:40 -07:00
orientor 6224d83dea middleware: Get client name in LogRequests instead of process_client.
This ensures it is present for all requests; while that was already
essentially true via process_client being called from every standard
decorator, this allows middleware and other code to rely on this
having been set.
2021-04-29 17:03:05 -07:00
Abhijeet Prasad Bodas 7f9c3bb4d0 starred messages: Fix "unstar all in topic" is incomplete.
Currently, when there are some old starred messages
in a topic, it is possible that some of them won't be
unstarred on doing "Unstar all messages in topic".
This happens when those messages haven't been fetched
yet from the server, and we have no way to verify if
they actually belong to the topic.

This commit fixes that by changing this mechanism to
first fetch all starred messages in the topic from
the server, and then send their IDs back to the backend
to unstar them.

While doing this, we assume that the user does not
have more than 1000 starred messages in that topic.

Note that, we still depend on the local data to
decide whether or not the "Unstar all messages in
topic" option should be shown in the topic popover.
A method similar to the above cannot be used here, because
making server requests before opening the popover
could visually slow down the popover opening.

Using local data for the topic popover would probably
not be a big problem, because users would want to
unstar all messages in a topic probably after noticing
that there are a lot of them, meaning there was at least
one starred message from that topic which was already
fetched, which is sufficient for us to conclude that
we need to show the option in the topic popover.

Fixes #17790
2021-04-29 16:43:39 -07:00
Abhijeet Prasad Bodas ded3d94f62 starred messages: Clean up "unstar all in topic" warning.
The dialog now shows `stream > topic` instead of
just the topic.
This creates a new tiny widget for this purpose,
which can be reused in other places too.

The `undefined` case is probably very unlikely, but
if the `stream_id` is bad, after the user confirms,
the request will fail on the backend, which could
confuse the user, since there will be no changes to
the starred messages in view.
So, we don't open the confirmation dialog at all in
such cases.
2021-04-29 16:43:39 -07:00
Abhijeet Prasad Bodas 29bf97313a message list: Stub with Error instead of asserting zero calls in tests.
This is a cleaner way of testing that the function
is not called, than using counters.

This code was added in 9cb41c2976.
2021-04-29 16:21:51 -07:00
Abhijeet Prasad Bodas 4bd7ec7c36 message lists: Rename update_items_for_muting to include `topic`.
This change will help avoid confusion with a similar
method which will be added in further commits for
user muting.
2021-04-29 16:21:38 -07:00
Abhijeet Prasad Bodas 10cfd25456 node tests: Remove redundant muting tests for message lists.
This logic is already thoroughly tested in node tests for
the `MessageListData` class, and the `unmuted_messages`
method of `MessageList` only directly call the corresponding
method of the data class.
2021-04-29 16:13:06 -07:00
Abhijeet Prasad Bodas 9d8bcce4c1 message_list: Don't store excludes_muted_topics twice.
There is no need to store this field (and make sure
that it's the same in both the message_list and
message_list_data objects) on message_list objects,
because we can anyways access it easily with
`message_list.data.excludes_muted_topics`, and storing
it just on the data object seems more intuitive.
This also simplifies the constructor for the `MessageList`
class.
2021-04-29 16:13:06 -07:00
Abhijeet Prasad Bodas 15e3420ee4 mute user: Hide from top left corner PM list.
We hide a conversation from the top-left corner PM list if
it is-
* A 1:1 PM where the other user has been muted, or
* Huddle where all users have been muted.
2021-04-29 16:13:06 -07:00
Abhijeet Prasad Bodas 615f79daaa node tests: Clean up data setup in pm_conversations.js.
* Extract out data as common variable so that it can
be reused in other tests in the future.
* Use consistent dummy user_ids across tests.
* Expand the data set to cover all possible cases-
  - 1:1 PMs
  - Huddles
  - PMs with self
2021-04-29 16:13:06 -07:00
Abhijeet Prasad Bodas 6769990324 node tests: Introduce `test` wrapper in pm_conversations.js. 2021-04-29 16:13:06 -07:00
Aman Agrawal 4a91d5ffdb compose_control_buttons: Change class name for GIF icon.
Since we no longer use giphy logo to open giphy
popover, this is a more appropriate name.
2021-04-29 16:06:51 -07:00
Aman Agrawal 818b4ee7f9 giphy: Don't change logo color in night mode.
Since giphy logo is no longer an svg, we don't need to change its
color.
2021-04-29 16:06:51 -07:00
Anders Kaseorg fc243854a8 docs: Note that Iterable is wrong for values iterated multiple times.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-29 16:06:17 -07:00
Anders Kaseorg 871e73ab8f mypy: Don’t use Iterable for values iterated multiple times.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-29 16:06:17 -07:00
Anders Kaseorg 393ffcb318 actions: Replace SizedTextIterable with standard Collection[str].
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-29 16:06:17 -07:00
Anders Kaseorg 48a52ac56e events: Convert recursion to a loop in do_events_register.
Fixes #18310.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-29 16:03:05 -07:00
Tim Abbott fd52c1b114 help: Lightly advertise moderator users role. 2021-04-29 15:52:24 -07:00
Tim Abbott a95cb97ceb help: Add basic documentation for organization moderators.
We'll extend this in the future with details on what is configurable,
but this at least ensures we don't have a state where they don't
appear in our documentation at all.
2021-04-29 15:49:02 -07:00
sahil839 06547d5c9b user_events: Update the role field in person object on change of role.
This commit adds code for live updating the role field of person
object on receiving role change event from server and thus enables
live update of role in users list of settings overlay.
2021-04-29 15:27:15 -07:00
sahil839 253a935cb2 user_events: Add code to live update is_moderator on role change.
This commit adds code to live update page_params.is_moderator and
person.is_moderator on receiving role change event.
The code for changing role to moderator and from moderator to any
other role was added in previous commit.
2021-04-29 15:18:49 -07:00
sahil839 730c0493b3 users: Show user role as 'moderator' in frontend for realm moderators.
This commit modifies the code to show "Moderator" correctly for
realm moderators.

As, we show role using settings_config.user_role_values object and
the same is used for showing options in changing role dropdown, this
commit also adds the moderator option in that dropdown and thus allows
the user to change role to moderator and from moderator to any other
role from frontend.
But the code for live updating page_params.is_moderator and
person.is_moderator will be in further commit.
2021-04-29 15:18:49 -07:00
sahil839 5332abcf6a settings: Add moderators option in frontend for invite_to_realm_policy.
This commit adds 'admins and moderators' option in frontend for
invite_to_realm_policy.

The logic for moderator for checking whether user is allowed to invite
others or not was added in previous commit as we use common helper
user_has_permission for all policies.
But the test user_can_invite_others_to_relam is updated for including
moderator role in this commit.
2021-04-29 15:18:49 -07:00
sahil839 6a58cf922f setting: Add moderator option in create stream and invite to stream policy.
This commit adds 'admins and moderators' option for create_stream_policy
and invite_to_stream_policy in frontend.
2021-04-29 15:18:49 -07:00
sahil839 f9503a4681 settings: Use role value directly to set user-role-select dropdown.
Since, we now have role value in the person objects sent from server
we can directly use that to set the value of dropdown used for
changing user role, instead of using multiple if-else conditions
for checking is_admin, is_owner, etc.
2021-04-29 15:18:49 -07:00
sahil839 77499589f9 users: Use role value directly to display user role text in frontend.
Since, we now get role value in person objects sent from server, we
can simply user user_role_map to display role in different places
instead of having multiple if-else conditions to check flags like
is_admin, is_guest, etc.
2021-04-29 15:18:49 -07:00
sahil839 4f354e28eb settings_users: Remove is_admin and is_guest fields from bot_info.
The is_admin and is_guest fields were used only by users and not
bots.
2021-04-29 15:18:49 -07:00
sahil839 bd78b1ff90 events: Add 'is_moderator' field to the page_params object sent to clients. 2021-04-29 15:18:49 -07:00
sahil839 dc771f3a14 users: Add support for changing user role to moderator in api.
This commit adds backend support for changing a user role to
moderator and also to change role from moderator to any other
role.
2021-04-29 15:17:45 -07:00
sahil839 34f134d58d users: Add role field to user objects returned by format_user_row.
This commit modifies the user objects returned by 'GET /users',
'GET /users/me', 'GET /users/{user_id}' and 'GET /users/{email}'
endpoints to include role field.

We also include role field in the page_params['realm_users'] dict
and in the person object sent in (type="realm_user", op="add")
event.
2021-04-29 15:13:50 -07:00
Alex Vandiver 8711ab7676 outgoing_webhook: Add a logging statement for each outgoing webhook.
This will help determine potentail timeout lengths, as well as serve
as a generally-useful log for locations which do not have Smokescreen
enabled.

In service of #17742.
2021-04-29 12:37:14 -07:00
Tim Abbott 03e155f38a docs: Add production documentation for custom management commands. 2021-04-29 12:36:13 -07:00
Adam Birds db16dd9d26
integrations: Change display name for Json integration to use a capital F.
Change display name for Json integration to use a cpital F instead of
lowercase which is the standard across the rest of our integrations.
2021-04-29 12:35:12 -07:00