Commit Graph

52475 Commits

Author SHA1 Message Date
Alex Vandiver cfda414277 export: Include huddles subscription from mirrordummy users.
If there are two huddles, with users A + B + C + D and A + B + C, and
user D is deleted, it is replaced with a mirrordummy user.  If
mirrordummy subscriptions are not included in exports, then the two
huddles have duplicate member sets, and will not be able to be
imported successfully.

Include huddle subscriptions for mirrordummy users in exports.
2023-07-17 17:22:57 -07:00
evykassirer d293e869bd search: Bold search operands in the first search result.
Specifically when it's the last operand of the search
filter. This makes the first line of search results
more consistent with the lines that come after.
2023-07-17 17:19:08 -07:00
evykassirer 8f5305a4ce search: Create a template for search descriptions. 2023-07-17 17:19:08 -07:00
evykassirer 6346110b56 search: Remove unused base_query variable. 2023-07-17 17:19:08 -07:00
evykassirer 7116526492 compose: Use compose_state.stream_id when name isn't needed.
This partially fixes #25742.
2023-07-17 16:30:39 -07:00
evykassirer afd703fe77 compose: Fix buggy recipient id code.
`selected_recipient_id` is supposed to be an id,
not a stream name. This function is currently
only ever called for direct messages, so there's
no present user-facing bug.
2023-07-17 16:30:39 -07:00
evykassirer 91d32d9f16 stream data: Store stream subscriptions by id instead of name.
This commit has no functional changes. An extra dict has been
added to preserve previous lookup times.
2023-07-17 16:30:39 -07:00
Lalit a240280c12 message_overlay_ui: Fix eslint errors for rule no-unnecessary-condition
This mainly fixes error related to if checks like - `if ($jquery[0] !==
undefined)` which is not a good way to check for existence of jquery
objects instead we should check the length of jquery collections for
these if checks.
2023-07-17 16:24:16 -07:00
Lalit c0c4c2e1e7 ts: Migrate `message_overlay_ui` to TypeScript. 2023-07-17 16:24:16 -07:00
Lalit b97926ba0c messages_overlay_ui: Remove support for `_e` parameter for
`modals_handle_events`.

We are not using the `_e` parameter here since this commit `4a3211d`, so
I removed this parameter from the `modals_handle_events` function.
2023-07-17 16:24:16 -07:00
Lalit ad10c77919 settings_user: Pass data of correct type to `list_widget.render_item`.
Since `list_widget.render_item` accepts the parameter of type `Item` and
not `Key`, therefore we should pass the actual item instead of just
plain id to the `render_item` function here.
2023-07-17 11:31:51 -07:00
Lalit d58085dde2 list_widget: Check length of JQuery collection instead of collection
itself.

We were checking for the undefined value of `$html_item` but this
variable is always true since `$.find` never returns an undefined value
and it returns a JQuery collection instead.

So we need to check the length of that JQuery collection here to make
sure that the condition works as expected.
2023-07-17 11:31:51 -07:00
Lalit ed7588152e list_widget: Remove over defensive validation code.
After migrating to TypeScript, we don't need to manually validate the
configuration passed to the `ListWidget`, that's what typescript complier
will do for us, hence I removed `validate_opts` and `valid_filter_opts`
functions.
2023-07-17 11:31:51 -07:00
Lalit b51bdd33bb ts: Migrate `list_widget` to TypeScript. 2023-07-17 11:31:51 -07:00
Lalit 08f84f0a45 list_widget: Set $scroll_container directly in `meta` object.
We should directly set the value of `$scroll_container` when making the
`meta` object in `list_widget` instead of setting it up later in
`set_up_event_handlers` function which gets called anyways on
widget initialization. This allows us to not make an incomplete type
object which typescript will complain about when we migrates this module to
TypeScript.
2023-07-17 11:31:51 -07:00
Lalit b04dfd8c29 list_widget: Explicitly pass generic sort functions to the list widget.
This is a prep commit for typescript migration of this module. In this commit
I made all the users of ListWidget pass generic sort functions like 'alphabetic'
and 'numeric' explicitly to avoid type conversions which we may need when moving
to typescript, also it simplifies our `set_sorting_function` a bit more.
2023-07-17 11:31:51 -07:00
Lalit 3720fd5c76 list_widget: Make `get_item` option required and pass a default where needed.
This is a prep commit for moving towards typescript migration of this module.
We should make `get_item` required on `list_widget` because its intended to be
used with a set of keys and then hydrate the keys lazily. Also this will help
us to avoid writing messy if-conditions while filtering and sorting and make
our life much easier when we migrate to TypeScript.

I added a `default_get_item` function which is just n identity function and
also refactored some code to make use of default get item.
2023-07-17 11:31:51 -07:00
Lalit 7176590eea list_widget: Add new parameter for getting insert index in `insert_rendered_row`.
We should keep methods of `list_widget` generic and independent of outer modules
data types and hence I added this parameter to get insert index to make
`insert_rendered_row` work with any list we create and not only `topic_list`.
2023-07-17 11:31:51 -07:00
Lalit e8390a529a list_widget: Refactor `widget` object.
This is a prep commit for migrating `list_widget` to TypeScript, In this
commit we declare all our methods for the widget directly inside `widget`
object to avoid making an incomplete object when we add a type for our widget.
2023-07-17 11:31:51 -07:00
Karl Stolley de23949a36 message_edit: Use CSS to manage preview scroll.
Fixes #26135.
2023-07-17 11:28:55 -07:00
David Rosa 8bd3c4ea2b help: Update "Text emphasis" page to be consistent with other pages.
- Adds "Examples" subheading.
- Adds Markdown includes for intro text and examples.
2023-07-17 11:17:24 -07:00
David Rosa 73213a444b help: Update sidebar title and related articles of Video calls page. 2023-07-17 11:17:24 -07:00
David Rosa 94caacaba9 help: Update sidebar title and related articles of Polls page. 2023-07-17 11:17:24 -07:00
David Rosa d03bd13550 help: Update sidebar title and related articles of Animated GIFs page. 2023-07-17 11:17:24 -07:00
David Rosa bfed711f54 help: Add a dedicated page on how to format paragraphs and sections. 2023-07-17 11:17:24 -07:00
David Rosa d127a6d317 help: Add a dedicated page on how to start a collaborative to-do list. 2023-07-17 11:17:24 -07:00
David Rosa 5f8d5eeb22 help: Add a dedicated page on how to format tables. 2023-07-17 11:17:24 -07:00
David Rosa 8c1e1f3f89 help: Add a dedicated page on how to format global times. 2023-07-17 11:17:24 -07:00
David Rosa 5c0e7ca43c help: Add a dedicated page on how to use /me action messages. 2023-07-17 11:17:24 -07:00
Alex Vandiver 003fa7adda message_edit: Lock the Message row in check_update_message.
Fundamentally, we should take a write lock on the message, check its
validity for a change, and then make and commit that change.
Previously, `check_update_message` did not operate in a transaction,
but `do_update_message` did -- which led to the ordering:

 - `check_update_message` reads Message, not in a transaction
 - `check_update_message` verifies properties of the Message
 - `do_update_message` starts a transaction
 - `do_update_message` takes a read lock on UserMessage
 - `do_update_message` writes on UserMessage
 - `do_update_message` writes Message
 - `do_update_message` commits

This leads to race conditions, where the `check_update_message` may
have verified based on stale data, and `do_update_message` may
improperly overwrite it; as well as deadlocks, where
other (properly-written) codepaths take a write lock on Message
_before_ updating UserMessage, and thus deadlock with
`do_update_message`.

Change `check_update_message` to open a transaction, and take the
write lock when first accessing the Message row.  We update the
comment above `do_update_message` to clarify this expectation.

The new ordering is thus:

 - `check_update_message` starts a transaction
 - `check_update_message` takes a write lock on Message
 - `check_update_message` verifies properties of the Message
 - `do_update_message` writes on UserMessage
 - `do_update_message` writes Message
 - `check_update_message` commits
2023-07-17 10:53:38 -07:00
Alex Vandiver fcf096c52e puppet: Remove unused zulip notification contact. 2023-07-17 10:52:36 -07:00
evykassirer 24a2ff5016 loading: Show error when spectator fails to register.
Fixes #25683.
2023-07-17 10:49:45 -07:00
evykassirer cb5441a6b0 search: Link messages in search results to near view.
Previously clicking on a message in search results opened
the compose box. This was not great, because search views
show messages outside of their context, and replying to a
message without the context of possible more recent
messages sent to that narrow can result in a bad experience.

This commit prevents the composebox from opening on click and instead
moves the user to a near view for the message, and similarly with the
enter keyboard shortcut.

Fixes #21217.
2023-07-17 10:39:43 -07:00
Lalit 61d4670f9a user_group_pill: Add test coverage for `append_user_group`. 2023-07-17 10:38:24 -07:00
Lalit 8aa6ddfe68 ts: Migrate `user_group_pill` module to TypeScript. 2023-07-17 10:38:24 -07:00
Lalit e06726a5cf peer_data: Remove over defensive `assert_number` function.
Removes the `assert_number` over defensive function which was being used
for validating the type of `stream_id` but now that this module is
converted to TypeScript we do not need this function anymore since
typescript compiler will do the type checking for us.
2023-07-17 10:37:29 -07:00
Lalit de6f21545b ts: Migrate `peer_data.js` to TypeScript. 2023-07-17 10:37:29 -07:00
abdullahm1 a0fb4feebf integrations: Replace use of 'subject' to 'topic'.
Fixes #25974
2023-07-17 10:35:51 -07:00
Hemant Umre 7036b0d466 left_sidebar: Avoid zooming out when toggling stream subscription.
In this commit, we have replaced `build_stream_list()` with
`update_streams_sidebar()`. This change avoids zooming out from the
"more topics" view when toggling your subscription to a different stream.
It also triggers a forced rerender of the left sidebar only when
unsubscribing from the currently active stream. The stream list will be
updated once the user zooms out.
2023-07-17 10:13:53 -07:00
Hemant Umre 30ab2781b1 left_sidebar: Fix exception exiting "more topics".
The `stream_list.build_stream_list()` function is responsible for
rendering the stream list in the left sidebar. Previously, it uses
`topic_list.clear()` to clear the `active_widgets` that tracks active
stream(s) in the left sidebar. This led to a bug where rendering stream
list after adding or removing a stream through `build_stream_list()`
while a stream was zoomed in ("more topics" clicked) didn't fully exit
the "more topics" view. So clicking "BACK TO STREAMS" throws an exception
with the message "Error: Unexpected number of topic lists to zoom out"
because `active_widgets`, cleared by `topic_list.clear()`, became
inaccessible.

To address this issue, instead of clearing the topics list with
`topic_list.clear()`, the code now ensures the closure of the zoomed
stream by using `topic_zoom.clear_topics()`. This change ensures a
proper exit from the "more topics" view and avoids the exception.

Fixes #25670.
2023-07-17 10:13:53 -07:00
Prakhar Pratyush 21a5818765 mention: Soft-reactivate users receiving @topic mention notifications.
The long-term idle topic participants are soft-reactivated
after email/push notifications are sent due to @topic mention.

The reason being that, generally, @topic mentions are going to
reach a small set of users who have a decent chance of being
reactivated by the notifications.
2023-07-17 09:39:24 -07:00
Prakhar Pratyush 4c9d26ce17 mention: Send notifications for @topic wildcard mentions.
This commit completes the notifications part of the @topic
wildcard mention feature.

Notifications are sent to the topic participants for the
@topic wildcard mention.
2023-07-17 09:39:24 -07:00
Steve Howell 67cdf1a7b4 emojis: Use get_emoji_data.
The previous function was poorly named, asked for a
Realm object when realm_id sufficed, and returned a
tuple of strings that had different semantics.

I also avoid calling it duplicate times in a couple
places, although it was probably rarely the case that
both invocations actually happened if upstream
validations were working.

Note that there is a TypedDict called EmojiInfo, so I
chose EmojiData here.  Perhaps a better name would be
TinyEmojiData or something.

I also simplify the reaction tests with a verify
helper.
2023-07-17 09:35:53 -07:00
Steve Howell b742f1241f realm emoji: Use a single cache for all lookups.
The active realm emoji are just a subset of all your
realm emoji, so just use a single cache entry per
realm.

Cache misses should be very infrequent per realm.

If a realm has lots of deactivated realm emoji, then
there's a minor expense to deserialize them, but that
is gonna be dwarfed by all the other more expensive
operations in message-send.

I also renamed the two related functions.  I erred on
the side of using somewhat verbose names, as we don't
want folks to confuse the two use cases. Fortunately
there are somewhat natural affordances to use one or
the other, and mypy helps too.

Finally, I use realm_id instead of realm in places
where we don't need the full Realm object.
2023-07-17 09:35:53 -07:00
Steve Howell e988cf9b0a emoji cache: Don't join to UserProfile table.
We only need author id, and anything else in the table
would be possibly stale anyway.
2023-07-17 09:35:53 -07:00
Zixuan James Li c257aa7fba integrations: Regenerate screenshots. 2023-07-17 09:23:01 -07:00
Zixuan James Li 604ffebf5f tools: Make screenshot tool work with the modern web client.
This fixes some deprecation use of the APIs, including using "new"
instead of "true" for the "headless" flag when launching puppeteer and
using $$ instead of $x when using XPath selectors.

We also use {waitUntil: "networkidle2"} to fix the issue of webhook bot
avatar not being loaded consistently when generating the screenshots
(this happened to webhooks like Slack and Harbor).

Positioning of the clip area is adjusted to take the new grid layout
into account.
2023-07-17 09:23:01 -07:00
Zixuan James Li d1455d81f2 integrations: Extend screenshot tool for more flexibility.
This allows the user to skip generating screenshots up to certain
integration when working through generating screenshots for all
integrations.

This also allow the user to select a number of integrations to
selectively generate screenshots for.
2023-07-17 09:23:01 -07:00
Zixuan James Li e8a6f6a313 integrations: Fix broken screenshots configuration.
Along with the fix, we add a test case to ensure that this never happens
again.
2023-07-17 09:23:01 -07:00
Zixuan James Li f89552c226 integrations: Add missing dependencies for screenshots.
message-screenshot.js stopped working because these dependencies were not
added to package.json.
2023-07-17 09:23:01 -07:00