Commit Graph

61263 Commits

Author SHA1 Message Date
Aditya Kumar Kasaudhan 8994266137 left-sidebar: Use -, _, :, and / as additional topic word separators.
Previously, only spaces were used as word separators when searching
for topics. This meant that searching for "support" would not find a
topic named "topic_support" or "topic/support," which could lead to
unexpected results.

To address this, hyphen (-), underscore (_), colon (:), and slash (/)
have been added as additional word separators for topic filtering in
the left sidebar, as these characters are commonly used as separators
in topic names.

Fixes: #31844
2024-10-04 14:18:43 -07:00
Prakhar Pratyush cf879a5f48 realm_export: Add a RealmAuditLog entry for delete operation.
This commit adds a RealmAuditLog entry for when someone deletes
an export.

This helps to track the acting_user.
2024-10-04 14:17:20 -07:00
Prakhar Pratyush 07dcee36b2 export_realm: Add RealmExport model.
Earlier, we used to store the key data related to realm exports
in RealmAuditLog. This commit adds a separate table to store
those data.

It includes the code to migrate the concerned existing data in
RealmAuditLog to RealmExport.

Fixes part of #31201.
2024-10-04 12:06:35 -07:00
Prakhar Pratyush 5d9eb4e358 realm_export: Save stats in '.json' format instead of '.txt'.
This commit updates code to store the realm export stats in
json format instead of plain text.

This will help in storing the stats as JsonField in RealmExport table.
2024-10-04 12:06:35 -07:00
Shubham Padia 6968d7374a compose: Change cursor to default instead of not-allowed.
Fixes #31214.
2024-10-04 11:40:15 -07:00
Shubham Padia 0634f75582 settings: Rearrange group settings in alphabetical order. 2024-10-04 11:15:01 -07:00
Shubham Padia 72de37e737 settings_data: Move spectator check to a single function.
Move spectator check to user_has_permission_for_group_setting.
2024-10-04 11:15:01 -07:00
Sayam Samal b09dfb782d reactions: Optimize DOM cost of message reactions via dynamic rendering.
Before, the message reactions section along with the add reaction button
was being rendered for every message even when there were no reactions
present - this led to additional DOM cost.

This commit adds the message reactions section only when there is
at least a single reaction on the message, and follows up with a cleanup
of the message reactions section when there are no reactions.

Fixes #31137.

Co-authored-by: Anmol-dev45 <basnetanmol2020@gmail.com>
2024-10-04 11:09:43 -07:00
Anders Kaseorg 1b4e02c5d0 thumbnail: Remove type: ignore.
(An alternate solution is message_classes: list[type[Message |
ArchivedMessage]].)

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-10-04 13:54:14 -04:00
Alex Vandiver 912c1b5984 thumbnail: Tighten and clarify the "type: ignore" limitation. 2024-10-04 09:10:14 -07:00
Alex Vandiver 3cbbf2307b thumbnail: Only lock the message row, not the Attachment row.
This prevents a deadlock between the thumbnailing worker and message
sending, as follows:

1. A user uploads an image, making Attachment and ImageAttachment
   rows, as well as enqueuing a job in the thumbnailing queue.

2. Message sending starts a transaction, creates the Message row,
   and calls `do_claim_attachments`, which edits the Attachment row
   of the upload (implicitly locking it).

3. The thumbnailing worker starts a transaction, locks the
   ImageAttachment row for its image, thumbnails it, and then
   attempts to `select_for_update()` the message objects (joined to
   the Attachments table) to find the ones which link to the
   attachment in question. This query blocks, since "a locking
   clause without a table list affects all tables used in the
   statement"[^1] and the message-send request already has a write
   lock on the Attachments row in question.

4. The message-send request attempts to re-fetch the ImageAttachment
   row inside the transaction, which tries to pull a lock on it.

5. Deadlock, because the message-send request has the Attachment
   lock, and waits for the ImageAttachment lock; the thumbnailing
   worker has the ImageAttachment lock, and waits for the Attachment
   lock.

We break this deadlock by limiting the
`update_message_rendered_content` `select_for_update` to only take
the lock on the Message table, and not also the Attachments table --
no changes will be made to the Attachments, so no lock is necessary
there. This allows the thumbnailing worker to successfully pull the
empty list of messages (since the message-send request has not
commits its transaction, and thus the Message row is not visible
yet), and release its ImageAttachment lock so that the message-send
request can proceed.

[^1]: https://www.postgresql.org/docs/current/sql-select.html#SQL-FOR-UPDATE-SHARE
2024-10-04 09:10:14 -07:00
Sahil Batra 74fb851958 settings: Do not store pill widgets for new groups in map.
Instead of storing setting pill widgets for new groups
in group_setting_widget_map, we just use variable in the
user_group_create file to store the widget.

This helps in accessing the widget with the key having
"new_group_" as prefix which we want to avoid as a pattern.

Note that the classes and IDs in templates still use
"new_group_" prefix.
2024-10-04 08:48:03 -07:00
Sahil Batra 698f3cf41b settings: Refactor code to get group setting pill widget value.
This commit refactors get_group_setting_widget_value function
to accept pill widget as parameter instead of setting name.

This is a prep commit for not needing to store the widgets for
group creation form in settings_components.group_setting_widget_map.
2024-10-04 08:48:03 -07:00
Sahil Batra 4b206b7394 settings: Refactor code to set group setting pill widget value.
This commit refactors set_group_setting_widget_value function
to accept pill widget as parameter instead of setting name.

This is a prep commit for not needing to store the widgets for
group creation form in settings_components.group_setting_widget_map.
2024-10-04 08:48:03 -07:00
Anders Kaseorg 7bd5ec28ae dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-10-04 08:47:07 -07:00
Anders Kaseorg 7bd0df408d eslint: Fix unicorn/prefer-math-min-max.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-10-04 08:47:07 -07:00
Anders Kaseorg 3b79a534a2 eslint: Fix unicorn/consistent-existence-index-check.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-10-04 08:47:07 -07:00
Pierre Carru 5cbe3203f5
slack_incoming: add ok=true to json in case of success.
This better simulates the Slack API, which is important, since some
integrations check this response and decide whether the Slack endpoint
is working based on what they receive.
2024-10-04 08:42:27 -07:00
Anders Kaseorg e7e8062b2e web: Add missing CSS.escape calls.
Any string interpolated into a CSS selector must be CSS escaped.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-10-04 08:39:30 -07:00
Greg Price 68e96bc73f contributor docs: Clarify how to claim a mobile issue
The existing text says to post a GitHub comment "saying that you'd
like to work on" the issue.  A lot of new contributors,
understandably, take that literally -- they just say they'd like to
work on the issue, with no further information.

In particular they don't give any evidence that they've taken the
steps we prescribe in the preceding section, of figuring out what code
is involved and how they'll approach the problem before they claim it.
When I reply asking for that information, very often they haven't done
those steps... while sometimes they have, and just hadn't put together
from context that that would be a good thing to communicate.

So spell that out explicitly.  Hopefully this will elicit smoother
communication from the contributors who have done that work; and
for those who haven't, hopefully it'll help redirect them to go back
and do it.

Also expand on the instruction not to spam.
2024-10-03 16:45:50 -07:00
Alex Vandiver ed8058d060 message: Do not differentiate topics by case when aggregating. 2024-10-03 16:35:45 -07:00
Anders Kaseorg a8304fb324 sentry: Address Sentry JavaScript 7.x deprecations.
https://docs.sentry.io/platforms/javascript/migration/v7-to-v8/

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-10-03 16:09:48 -07:00
Shubham Padia e9b031c003 help: Refer to group settings for create/manage group at org level.
Right now, we are referring to the roles instead of groups since we have
not enabled that UI for these settings.
2024-10-03 15:18:40 -07:00
Aman Agrawal 1b47134d0d sponsorship: Fix `#organization-type` not found.
The sponsorship form is not visible once user submits the form,
hence we don't to call these functions.
2024-10-03 09:25:47 -07:00
Lauryn Menard 1e7f2fe6dd docs: Add missing links to web-public channels in dev community. 2024-10-03 09:15:51 -07:00
Anders Kaseorg 9c2da46966 filter: Fix unparse to round-trip Unicode whitespace operands.
Previously [{operator: "topic", operand: "one\xa0two"}] would be
unparsed to "topic:one\xa0two" which parses as [{operator: "topic",
operand: "one"}, {operator: "search", operand: "two"}], leading to
exceptions in the search pill system.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-10-03 09:14:31 -07:00
roanster007 81efecf463 stream_topic_history: Update history to only store acked message ids.
Previously, the "stream_topic_history" used to store unacked float
message ids as well in its "max_message_id" of stream and
"message_id" of topic histories.

This commit updates it to rather store only the acked message ids
here, and rather use the "echo_state" module so as to look up
for unacked messages in case of looking for recent topics, or
max message id in functions.
2024-10-02 18:31:32 -07:00
roanster007 da75fed5be echo: Start tracking local messages before updating sidebars.
Previously, when `insert_local_message` was called, the
data structures in the `echo_state` are updated with the new
local messages after calling `insert_new_message`. This would
update the stream sidebar before even updating the `echo_state`
with the new local messages.

This commit introduces `track_local_message`, which basically
updates the `echo_state` data structures with the local
message before actually updating the stream sidebar.

This is a preparatory commit to update stream_topic_history
to only contain acked message ids.
2024-10-02 18:31:32 -07:00
Tim Abbott 3f307f5941 message_view_header: Remove unnecessary complexity.
The narrow_state module has a function that returns what this needs.

This does remove a log statement, but I don't think it was useful; we
don't need to or have a useful way to colorize a channel that doesn't
exist.
2024-10-02 17:42:02 -07:00
roanster007 359ebfc6c8 filter: Refactor code path which adjusts the narrow containing `with`.
This commit refactors the `ensure_channel_topic_terms` of filter.ts.
Previously, this method used to add channel and topic terms, with
operands as placeholders in case the `with` narrow doesn't have
channel-topic terms.

This commit updates it to rather correct the narrow with the right
terms in case the channel-topic terms are missing in the `with`
narrow, but leave it as it is in case the channel-topic terms are
present, so that it can later be corrected if the channel-topic
terms are not pointing to the right conversation.
2024-10-02 16:22:59 -07:00
Sayam Samal 0a9ae964fe send_later_popover: Improve on-focus styling of enter send choices.
Previously, no custom styling was being applied to the enter send
choice options, which led to uneven styling from the other popover
options, as well as the outline ring being cut-off from the edges of
the popover. This commit fixes these issues by adding custom styling
for the outline ring when the enter send choice options are focused.
2024-10-02 14:35:37 -07:00
Sahil Batra e19f4ed2a8 user_groups: Do not allow click events on disabled pill container.
The typeahead should not open on clicking the pill container when
the container is disabled when the user is not allowed to change
the setting.
2024-10-02 14:23:37 -07:00
Alex Vandiver b4b1551b81 tusd: Do not delete the .info files.
These files are necessary for the protocol to verify that the file
upload was completed successfully.  Rather than delete them, we update
their StorageClass if it is non-STANDARD.
2024-10-02 13:21:04 -07:00
Tim Abbott 1ff14fd0f1 analytics: Pass subgroup=None to improve indexing.
Because the main indexes on end_time either don't include realm_id or
do include subgroup, passing an explicit subgroup=None for
single-realm queries to read CountStats that don't use the subgroups
feature greatly improves the query plans.
2024-10-02 14:11:44 -04:00
evykassirer 9c8cc8c333 buddy_data: Add participants to the top of sorted user list.
This was causing a bug where the participants weren't necessarily
all getting rendered, specifically when there were many subscribers
to a channel, because we render users in batches as buddy list
scrolls, and those users would only show up after some scrolling.

This fix makes sure we always load the participants first.
2024-10-02 09:33:48 -07:00
Aman Agrawal 8e5672dd98 message_view: Fix narrow to compose recipient rerenders in same narrow.
We don't rerender if we are already narrowed to the compose recipient.
2024-10-02 09:32:18 -07:00
opmkumar ee70cd8af3 saved_snippet: Prepopulate new saved snippet content.
Fixes #31827.
2024-10-02 09:30:18 -07:00
Tim Abbott 2807d7fbb8 dropdown_widget: Use CSS variable for disable color. 2024-10-01 18:21:33 -07:00
Tim Abbott 119fa699a7 message_view: Fix invalid target message assumption.
The target_message is just whatever message has the ID in a /near/ or
/id/ link; there's no guarantee it's a channel message.
2024-10-01 17:59:59 -07:00
Tim Abbott 0fa4cd9d09 message_view: Remove incorrect assert for p keyboard shortcut.
This happens routinely when the current view is not a DM view.
2024-10-01 17:47:45 -07:00
Shubham Padia b4d377a2fa settings: Test named and anonymous groups for org level group settings. 2024-10-01 17:35:14 -07:00
Shubham Padia 12ebd97f1f settings: Add group_creator as default for can_manage_group.
We create an unnamed user group with just the group creator as it's
member when trying to set the default. The pattern I've followed across
most of the acting_user additions is to just put the user declared
somewhere before the check_add_user_group and see if the test passes.
If it does not, then I'll look at what kind of user it needs to be set
to `acting_user`.
2024-10-01 17:35:14 -07:00
Shubham Padia 91edf59873 settings: Rename can_edit_all_user_groups to use `manage`.
Having both `manage` and `edit` terminologies was confusing, so
this commit ensures that we use `manage` wherever applicable.
2024-10-01 17:35:14 -07:00
Shubham Padia 4d06626b6f realm: Remove user_group_edit_policy from the backend.
Fixed #25929.
2024-10-01 17:35:14 -07:00
Shubham Padia b7764eb6f0 settings: Remove user_group_edit_policy from the frontend. 2024-10-01 17:35:14 -07:00
Shubham Padia f0b9d610a5 settings: Use `can_manage_all_groups` to control who can manage groups.
We also add the exception for the group creator to be able to edit their
group in this commit. This exception was added in the backend in earlier
commits.
2024-10-01 17:35:14 -07:00
Shubham Padia 6e9d56eaf4 user_groups: Check permission to manage groups based on group setting.
We also add exception for the group creator to manage groups. See
https://chat.zulip.org/#narrow/stream/3-backend/topic/Group.20creation.20-.20who.20can.20change.20the.20setting.2E/near/1943861
for more details. For the tests, wherever possible, we've just added an
acting_user when creating a group to test.
We've also added an acting_user argument to create_user_group_for_test.
We will not remove `user_group_edit_policy` yet. That will be removed
once we have introduced this setting to the frontend.
2024-10-01 17:35:14 -07:00
Shubham Padia 91953eca28 realm: Only owners should be able to configure `can_manage_all_groups`. 2024-10-01 17:35:14 -07:00
Shubham Padia 2b6414acfb settings: Add can_manage_all_groups setting to realm.
This commit does not add the logic of using this setting to actually
check the permission on the backend. That will be done in a later
commit.
Only owners can modify this setting, but we will add that logic in a
later commit in order to keep changes in this commit minimal.
Adding the setting breaks the frontend, since the frontend tries to find
a dropdown widget for the setting automatically. To avoid this, we've
added a small temporary if statement to `settings_org.js`.
Although, most lists where we insert this setting follow an unofficial
alphabetical order, `can_manage_all_groups` has been bunched together
with `can_create_groups` since keeping those similar settings together
would be nicer when checking any code related to creating/managing a
user group.
2024-10-01 17:35:14 -07:00
Shubham Padia a9e14a184c settings: Use `can_create_groups` to control who can create user groups. 2024-10-01 17:35:14 -07:00