Commit Graph

50077 Commits

Author SHA1 Message Date
Aman Agrawal 343536d4bc css: Remove blue color, underline and transition effect from msg time.
This looks most likely a regression. Added `.messagebox-content`
to move priority of color set by us on `.messsage_time` above others.
2023-02-23 14:30:20 -08:00
Aman Agrawal 5a3d3f5303 css: Use variables for colors used to display message time.
This makes color changes easy to review and maintain in the
codebase.

This is also an attempt towards removing dark_theme.css
as we will only need to override color variables for these
elements in `body.dark-theme` in zulip.css without need of
overriding colors for any specific elements.
2023-02-23 14:30:19 -08:00
Alex Vandiver 97a5690f55 timestamp: Switch to a slightly faster datetime_to_timestamp.
This is quite a bit faster:
```
%timeit calendar.timegm(now.timetuple())
    2.91 µs ± 361 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)

%timeit int(now.timestamp())
    539 ns ± 27 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)
```

This is particularly important for the presence endpoint, which is a
tight loop of serializing datetimes.
2023-02-23 12:15:13 -08:00
David Rosa 95867e6f3e help: Document dark-theme mobile feature.
- Documents "Night mode" option.
- Adds Related articles section.
2023-02-23 11:48:59 -08:00
Alya Abbott faa69940d7 help: Add section on privacy settings to /help/review-your-settings.
Also move "Review your settings" page to the "Account basics" section
in the left sidebar.
2023-02-23 11:48:32 -08:00
Alex Vandiver aa032bf62c queue: Only set QOS on a newly-opened channel, once.
As written, the QOS parameters are (re)set every time ensure_queue is
called, which is every time a message is enqueued. This is wasteful --
particularly QOS parameters only apply for consumers, and setting them
takes a RTT to the server.

Switch to only setting the QOS once, when a connection
is (re)established.  In profiling, this reduces the time to call
`queue_json_publish("noop", {})` from 878µs to 150µs.
2023-02-23 11:47:43 -08:00
Anders Kaseorg d145644f85 ruff: Fix PLE0101 Explicit return in `__init__`.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-23 11:47:08 -08:00
Alex Vandiver f78c2eab2c message_send: Use stream object for name in "no subscribers" message.
In the case where a stream existed but had no subscribers, the error
message used to send to the owner always used `stream_name`, which
may have been None.

Switch to using `stream.name` rather than `stream_name` for this case.
2023-02-23 11:02:55 -08:00
Alex Vandiver 6427d85cf6 tornado: Replace dataclasses.asdict() call, as it is slow.
This code is called in the hot path when Tornado is processing events.
As such, making this code performant is important.  Profiling shows
that a significant portion of the time is spent calling asdict() to
serialize the UserMessageNotificationsData dataclass.  In this case
`asdict` does several steps which we do not need, such as attempting
to recurse into its fields, and deepcopy'ing the values of the fields.

In our use case, these add a notable amount of overhead:
```py3
from zerver.tornado.event_queue import UserMessageNotificationsData
from dataclasses import asdict
from timeit import timeit
o = UserMessageNotificationsData(1, False, False, False, False, False, False, False, False, False, False, False)
%timeit asdict(o)
%timeit {**vars(o)}
```

Replace the `asdict` call with a direct access of the fields.  We
perform a shallow copy because we do need to modify the resulting
fields.
2023-02-23 11:01:38 -08:00
Anders Kaseorg ed069ebe0e docs: Remove spaces before commas.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-22 17:17:25 -08:00
evykassirer 541d3ffa06 compose: Replace empty message banner with red outline for compose box.
Previously, we showed an empty message banner if the user tried
to send an empty message. We only showed it for users with
"ctrl+enter to send" because we thought it might be easy for a
user to press just enter accidentally.

However, this missed the case where the user clicks on the Enter
button. We want to show the user something in this case to tell
them that they're missing message content.

To avoid more complicated logic, this PR removes the banner
completely and changes the compose box border to red if the
user tries to send an empty message (for all cases).

The red line goes away as soon as the composebox has non-whitespace
characters.
2023-02-22 17:15:18 -08:00
Tim Abbott 631ca13428 Revert "typeahead: Fix bug where typeahead showed momentarily on shift + tab."
This reverts commit 9def249af1.

This broke the '>' typeahead.
2023-02-22 17:07:06 -08:00
Sahil Batra 678d16a908 migrations: Fix extra_data of RealmAuditLog objects.
This commit adds migration to fix extra_data field
of RealmAuditLog objects created on changing
can_remove_subscribers_group setting to add "property"
field since the same event type will now be used for
other group based stream settings that will be added
in future.
2023-02-22 12:17:46 -08:00
Sahil Batra 0cf99cf5c3 streams: Refactor code to set group-based stream settings.
We add stream_permission_group_settings object which is
similar to property_types framework used for realm settings.

This commit also adds GroupPermissionSetting dataclass for
defining settings inside stream_permission_group_settings.

We add "do_change_stream_group_based_setting" function which
is called in loop to update all the group-based stream settings
and it is now used to update 'can_remove_subscribers_group'
setting instead of "do_change_can_remove_subscribers_group".

We also change the variable name for event_type field of
RealmAuditLog objects to STREAM_GROUP_BASED_SETTING_CHANGED
since this will be used for all group-based stream settings.

'property' field is also added to extra_data field to identify
the setting for which RealmAuditLog object was created.

We will add a migration in further commits which will add the
property field to existing RealmAuditLog objects created for
changing can_remove_subscribers_group setting.
2023-02-22 12:17:46 -08:00
Sahil Batra 416c7c2199 user_groups: Add require_system_group parameter.
This commit adds require_system_group parameter to
get_realm_user_groups_for_dropdown_list_widget.
We currently pass this parameter as "true" always,
but this will be needed in future when we will allow
to set groups other than system groups in settings.
2023-02-22 12:17:46 -08:00
Alya Abbott 3e7de4cc64 docs: Fix typo on Design discussions doc. 2023-02-22 12:00:24 -08:00
Hemant Umre 2e2b4f5325 stream_settings: Fix Announce stream disables unexpectedly.
While switching from a private stream in the stream editing UI to
the stream creation UI, Announce stream becomes disabled. The state
of Announce stream option should not be affected by where the create
stream UI is opened.

Made the privacy_type selector more specific since it was also
selecting the last opened stream privacy type.

Fixes: #24238.
2023-02-22 11:53:26 -08:00
Alex Vandiver 95abcffb75 log-search: Fix precedence in no-color case. 2023-02-22 11:43:13 -08:00
Lauryn Menard 0019ce639c api-docs: Fix small typos and copy/paste errors in API changelog. 2023-02-22 08:48:22 -08:00
Mateusz Mandera 52515a1560 presence: Tweak and document presence tuning values.
We're changing the ping interval from 50s to 60s, because that's what
the mobile apps have hardcoded currently, and backwards-compatibility
is more important there than the web app's previously hardcoded 50s.

For PRESENCE_PING_INTERVAL_SECS, the previous value hardcoded in both
clients was 140s, selected as "plenty of network/other latency more
than 2 x ACTIVE_PING_INTERVAL_MS". This is a pretty aggressive value;
even a single request being missed or 500ing can result in a user
appearing offline incorrectly. (There's a lag of up to one full ping
interval between when the other client checks in and when you check
in, and so we'll be at almost 2 ping intervals when you issue your
next request that might get an updated connection time from that
user).

To increase failure tolerance, we want to change the offline
threshhold from 2 x ACTIVE_PING_INTERVAL + 20s to 3 x
ACTIVE_PING_INTERVAL + 20s, aka 140s => 200s, to be more robust to
temporary failures causing us to display other users as offline.

Since the mobile apps currently have 140s and 60s hardcoded, it should
be safe to make this particular change; the mobile apps will just
remain more aggressive than the web app in marking users offline until
it uses the new API parameters.

The end result in that Zulip will be slightly less aggressive at
marking other users as offline if they go off the Internet. We will
likely be able to tune ACTIVE_PING_INTERVAL downwards once #16381 and
its follow-ups are completed, because it'll likely make these requests
much cheaper.
2023-02-21 12:10:43 -08:00
Mateusz Mandera 8ef889f392 presence: Use server-provided params in the webapp.
As of the previous commit, the server provides these parameters in
page_params. The defaults match the values hard-coded in the webapp so
far - so get rid of the hard-coded values in favor of taking them from
page_params.
2023-02-21 12:10:43 -08:00
Mateusz Mandera a593089770 presence: Return some presence params in the /register response. 2023-02-21 12:10:43 -08:00
Mateusz Mandera 4ba4305ff9 presence: Change server-side OFFLINE_THRESHOLD_SECS to 140s.
This old 300s value was meaningfully used in 2 places:
1. In the do_change_user_settings presence_enabled codepath when turning
   a user invisible. It doesn't matter there, 140s is just since the
   point is to make clients see this user as offline. And 140s is the
   threshold used by clients (see the presence.js constant).
2. For calculating whether to set "offline" "status" in
   result["presence"]["aggregated"] in get_presence_backend. It's fine
   for this to become 140s, since clients shouldn't be looking at the
   status value anymore anyway and just do their calculation based on
   the timestamps.
2023-02-21 12:10:43 -08:00
Alex Vandiver 38b7ecff68 log-search: Add a --timeline option to show gaps and overlaps. 2023-02-21 11:10:24 -08:00
Alex Vandiver cfd9e56d1a log-search: Do no use color codes if output is not a TTY. 2023-02-21 11:10:24 -08:00
Sahil Batra 33d06af6c2 user_profile: Deduplicate code for showing custom profile fields.
This commit deduplicates template code for showing custom profile
fields in user info popover and full profile modal by extracting
it in a new file and then using that template file to render
the fields in user info popover and full profile modal.

This commit does not change the design or behavior and they are
same as before.
2023-02-21 10:19:47 -08:00
Alex Vandiver bd6b215cdc sentry: Fix accidental blockquote by escaping >. 2023-02-21 09:59:13 -08:00
Alex Vandiver ab9cab51de reset: Tag "forgot password" text for translation. 2023-02-21 09:16:22 -08:00
Abhijeet Prasad Bodas 6e001d0672 user topic: Remove unnecessary check for double addition of muted topic.
This makes use of the new case insensitive UNIQUE index added in the
earlier commit. With that index present, we can now rely solely on the
database to correctly identify duplicates and throw integrity errors as
required.
2023-02-20 21:04:13 -08:00
Abhijeet Prasad Bodas 80bf6b0777 user topic: Add case insensitive UNIQUE constraint.
This will allow us to rely on the database to detect duplicate
`UserTopic`s (with the same `topic_name` with different cases)
and thus correctly throw IntegrityErrors when expected.
This is also important from a correctness point of view, since as
of now, when checking if topic is muted or requesting the backend for
muting a topic, the frontend does not check for case insensitivity.

There might exist duplicate UserTopics (in a case insensitive sense)
which need are removed before creating the new index.
The migration was tested manually using `./manage.py shell`.
2023-02-20 21:04:13 -08:00
Abhijeet Prasad Bodas 9fde88796a mute user: Remove unnecessary check for double muting.
In 141b0c4, we added code to handle races caused by duplicate muting
requests. That code can also handle the non-race condition, so we don't
require the first check.
2023-02-20 21:04:13 -08:00
Sahil Batra ca70089842 settings: Fix disabled select elements in modal.
The background-color and opacity is same for all
select elements in modals and settings in disabled
state, but due to the background of modal being
bright enough, the select element in modals would
not look disabled.

One possible solution could have been to set
"opacity: 1" but that changes opacity for text too
and makes it darker which is not the case for other
select elements.

So instead made the background slightly darker for
select elements inside the modal using hsla property.
It might not be exact same as the other select elements,
but it is still better than the previous behavior.

For role element in bot edit form, we used to set
opacity to 1 to fix this bug, and this commit removes
it as we have fixed it for all modals in general
2023-02-20 16:28:41 -08:00
Sahil Batra 1c055f402d settings: Add bootstrap-focus-style to select elements.
The class "bootstrap-focus-style" was not added to some
select elements in modals and this commit adds those.
2023-02-20 16:28:41 -08:00
Sahil Batra 27d2ac1e37 settings: Remove some duplicate CSS.
Since we added settings_select class to select elements
in both stream settings and user or realm settings in
previous commits, we can have common CSS defined at only
one place.
2023-02-20 16:28:41 -08:00
Sahil Batra c6ff8f0551 modals: Add modal_select class to select elements.
This commit adds modal_select class to select elements in
modals, such that we can add CSS using this class and not
using "select" as selector so that we can easily add a
select element in future with different CSS if needed.
2023-02-20 16:28:41 -08:00
Sahil Batra 6bd650bc9f stream_settings: Add settings_select class to select elements.
This commit adds settings_select class to select elements in
stream settings, such that we can add CSS using this class and
not using "select" as selector so that we can easily add a select
element in future with different CSS if needed.
2023-02-20 16:28:41 -08:00
Sahil Batra 1afc730da7 settings: Add settings_select class to select elements.
This commit adds settings_select class to select elements in
user and organization settings, such that we can add CSS
using this class and not using "select" as selector so that
we can easily add a select element in future with different
CSS if needed.
2023-02-20 16:28:41 -08:00
Sahil Singh 183f5016a1 settings: Indicate character limit on restoring long draft messages.
Currently, when restoring drafts with long
messages no character limit or the compose
banner is shown.

We fix this by adding a check for text
overflow whenever any draft is restored.
2023-02-20 16:23:08 -08:00
Aman Agrawal 845e873c44 narrow_state: Add function to check if message feed is visible.
We directly check if message feed is visible in the code instead
of indirectly checking so via recent topics. This helps read the
code clearly and would be helpful with the upcoming inbox view.
2023-02-20 13:08:42 -08:00
Aman Agrawal cc96be2bf9 recent_conversation: Delegate profile click handling to `body`.
`#recent_topics_table` may not be present in the DOM when
this click handler is initialized which can cause this
it to not work, delegating it to body ensures it will always work.
2023-02-20 13:04:13 -08:00
Aman Agrawal 4debef64e7 recent_conversation: Move click handlers out to an initialize function.
We are moving in the direction of removing click_handlers library.
2023-02-20 13:04:13 -08:00
Aman Agrawal 6e6fb47e20 muted_topics_ui: Extract mute_or_unmuted_topics. 2023-02-20 13:04:13 -08:00
Lauryn Menard 06dd6f8254 message-send: Deduplicate check of `settings.MAX_MESSAGE_LENGTH`.
Removes the initial check in `_internal_prep_message` of the length
of the message content because the `check_message` in the try block
will call `normalize_body` on the message content string, which
does a more robust check of the message content (empty string, null
bytes, length). If the message content length exceeds the value of
`settings.MAX_MESSAGE_LENGTH`, then it is truncated based on that
value. Updates associated backend test for these changes.

The removed length check would truncate the message content with a
hard coded value instead of using the value for
`settings.MAX_MESSAGE_LENGTH`.

Also, removes an extraneous comment about removing null bytes. If
there are null bytes in the message content, then `normalize_body`
will raise an error.

Note that the previous check had intentionally reduced any message over
the 10000 character limit to 3900 characters, with the code in
question dating to 2012's 100df7e349.

The 3900 character truncating rule was implemented for incoming emails
with the email gateway, and predated other features to help with
overly long messages (better stripping of email footers via Talon,
introduced in f1f48f305e, and
condensing, introduced in c92d664b44).
While we could preserve that logic if desired, it likely is no longer
a necessary or useful variation from our usual truncation rules.
2023-02-20 12:55:15 -08:00
Alex Vandiver 93e78ea72f spectators: Save a redirect to /register/. 2023-02-20 12:21:33 -08:00
Anders Kaseorg 64f0dcecb0 install-node: Upgrade Node.js to 18.14.1 security release.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-20 12:16:28 -08:00
Anders Kaseorg 99f1d08786 styles: Hoist @keyframes to top level.
This has always been in the global namespace.  Pretending that it’s
scoped when it isn’t and giving it a short name will lead to
confusion.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-20 12:10:18 -08:00
Anders Kaseorg f99cff0735 styles: Fix flatpickr dark theme in automatic mode.
Flatpickr had been unconditionally using the light theme in automatic
color scheme mode; this fixes it to follow the system preference like
the rest of the app.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-02-20 12:09:52 -08:00
Alex Vandiver d3403dde86 rabbitmq: Add a RABBITMQ_PORT setting. 2023-02-20 12:04:25 -08:00
Lauryn Menard 0463b0df7b api-docs: Update content parameter for `max_message_length`.
Updates the descriptions of content parameters (optional and
required) to note that the maximum size of the message content
should be based on the `max_message_length` value returned by
the register endpoint.

Previously these descriptions had a hardcoded value of 10000
bytes as the maximum message size.

Also, updates the description of `max_message_length` to clarify
that the value represents Unicode code points.
2023-02-20 12:03:12 -08:00
Lauryn Menard b25cba16a7 tests: Remove ignored parameter from `authenticated_json_view` test.
The password parameter being passed in the `_do_test` helper
function for `TestAuthenticatedJsonPostViewDecorator` tests was
being ignored, as the user needs to be logged in. Removes the
parameter from the helper function and updates the success test
to use `assert_json_success` instead of just checking the status
code.

Also adds a test case for when a user is not logged in to confirm
that it returns an UnauthorizedError.
2023-02-20 11:56:00 -08:00