Commit Graph

1725 Commits

Author SHA1 Message Date
Discourse Translator Bot
28c5fb94d3
Update translations (#29335) 2024-10-22 22:44:33 +09:00
Jarek Radosz
b9ec9c7e4f
DEV: Update more asserts to qunit-dom (#29326)
regex find&replace + removing now-unused imports + manually fixing incorrect css selectors (that now got flagged 😌) + manually updating selectors that relied on jq
2024-10-22 11:34:23 +02:00
Loïc Guitaut
08e9364573 DEV: Refactor some services from chat
Extracted from https://github.com/discourse/discourse/pull/29129.

This patch makes the code more compliant with the upcoming service docs best practices.
2024-10-21 16:16:25 +02:00
David Battersby
16acba6cf8
DEV: serialize image upload thumbnail (#29276)
Since we recently blocked accidental serialization of AR models, we are getting a 500 error in some cases with thumbnails. We can fix this by serializing the thumbnail, previously we just returned a raw OptimizedImage object.

Thumbnails are now attached to the serializer in core, therefore we no longer need to use add_to_serializer within the chat plugin to use thumbnails within chat message uploads.
2024-10-18 12:55:14 +04:00
Loïc Guitaut
23c486799f DEV: Improve array type in service contracts
This patch improves the custom `array` type available in contracts.
It’s now able to split strings on `|` on top of `,`, and to be more
consistent, it also tries to cast the resulting items to integers.
2024-10-17 17:02:02 +02:00
Loïc Guitaut
af6788fd33 DEV: Extract leave logic to the Chat::Channel model
Extracted from https://github.com/discourse/discourse/pull/29129.
2024-10-17 14:58:45 +02:00
David Taylor
7b8ebebe93
DEV: Fix regression in uppy-mixin (#29252)
This API change was unintentionally introduced in 06d32a8a89

Partially reverts 23d90ecb26, but keeps the new specs.
2024-10-17 10:38:19 +01:00
Loïc Guitaut
93e02069b0 DEV: Don’t provide an array to site settings group lists in specs
This is extracted from https://github.com/discourse/discourse/pull/29129.

In some chat specs, we provide an array as a value for group lists like
`chat_allowed_groups`, which is wrong. This results in a value like
`"1|2|[3]"` instead of `"1|2|3"`.
2024-10-17 11:25:31 +02:00
Joffrey JAFFEUX
23d90ecb26
FIX: _uploadDropTargetOptions is now public (#29246)
Chat was using a private function which has now been made public.

This commit also adds a test for this codepath.
2024-10-17 13:10:01 +09:00
David Battersby
6e6dbde898
DEV: move chat time formats to core locales (#29236)
This change moves the date/time formats to core locales, so that they can be used outside of the plugin.
2024-10-16 20:10:40 +04:00
Loïc Guitaut
76aa9b66d0 DEV: Allow ChatSDK.create to take extra parameters
Currently, `ChatSDK.create` restricts what parameters can be provided to
the underlying service. This prevents the `discourse-ai` plugin from
using it in one of its specs.

This patch allows extra parameters to be provided.
2024-10-16 17:34:01 +02:00
David Battersby
6078fb73ea
UX: consistent chat message date format (#29232)
In certain locales like English (GB), If a user posted 2 subsequent messages, the first would have a date displayed in 24 hour format, while the second message would be shown in 12 hour format (when hovering the message).

This change forces both messages to display in 12 hour format, the first message showing the am/pm, and the second showing the smaller version without am/pm.
2024-10-16 21:51:04 +08:00
David Taylor
06d32a8a89
DEV: Refactor uppy component mixins into standalone classes (#28710)
This commit replaces all uppy-related mixins with standalone classes. The main entrypoint is now lib/uppy/uppy-upload.js, which has a list of its config options listed at the top of the file. Functionality & logic is completely unchanged.

The uppy-upload mixin is replaced with a backwards-compatibility shim, which will allow us to migrate to the new pattern incrementally.
2024-10-16 11:15:19 +01:00
Discourse Translator Bot
e5f2416eff
Update translations (#29212) 2024-10-16 17:52:01 +09:00
Alan Guo Xiang Tan
322a3be2db
DEV: Remove logical OR assignment of constants (#29201)
Constants should always be only assigned once. The logical OR assignment
of a constant is a relic of the past before we used zeitwerk for
autoloading and had bugs where a file could be loaded twice resulting in
constant redefinition warnings.
2024-10-16 10:09:07 +08:00
Jarek Radosz
688f65a39d
DEV: Convert more test assertions to qunit-dom (#29214)
the PR is sponsored by vscode's regex support in find-and-replace 😉
2024-10-15 17:11:20 +02:00
Bianca Nenciu
8016fcab33
DEV: Drop old notification id columns (#28550)
The `id` column of `notifications` table and `notification_id` columns
of the other tables have been migrated to bigint in previous commits
(for example, 799a45a).

In order to run the migrations with zero downtime, the data had to be
copied to new columns and swapped, but the old columns have been kept
to allow for rollback. They are no longer needed now.
2024-10-15 11:58:57 +03:00
chapoi
c1325dbe13
UX: prevent unread indicator from shrinking in flexbox (#29207) 2024-10-15 10:08:45 +02:00
Martin Brennan
6c6cdd96e9
UX: Bump up chat delete messages limit (#29202)
50 is pretty restrictive, let's do 200 for now
2024-10-15 13:15:40 +10:00
David Battersby
492cf52bab
FIX: trashed channel thread view bug (#29192)
When chat channels are deleted, some users may be able to click the thread before it gets removed from the UI. This leads to a 500 error causing log noise. We can use the safe navigational operator to prevent calling chatable when the channel is not found (due to deleted_at constraint in query).
2024-10-14 17:45:50 +04:00
chapoi
1695971523
UX: change thread button in chat nav to use btn-transparent (#29186) 2024-10-14 09:25:27 +02:00
David Battersby
79d2eb5beb
FEATURE: enable threading in chat DM channels (#29170)
Support threads in DMs and group chats so members can keep their conversations organized.

This change adds a new toggle switch for threads within the Chat Channel Settings screen. For new direct message channels threading is enabled by default.

We have made a decision to exclude direct message threads from the My Threads screen for now.
2024-10-11 13:05:07 +04:00
Martin Brennan
2193667e1f
FIX: Plugin JS failing to load would break admin interface (#29139)
If a plugin's JS fails to load for some reason, most commonly
ad blockers, the entire admin interface would break. This is because
we are adding links to the admin routes for plugins that define
them in the sidebar.

We have a fix for this already in the plugin list which shows a warning
to the admin. This fix just prevents the broken link from rendering
in the sidebar if the route is not valid.
2024-10-11 09:26:10 +10:00
Bianca Nenciu
33a4ab13b5
DEV: Set bigint sequences to start at MAX_INT (#28961)
This helps uncover issues with bigint columns that are joined with int
columns. It also introduces a temporary API for plugins to migrate int
columns to bigint in test environment to make tests pass.
2024-10-10 19:28:45 +03:00
chapoi
3c03d9b1e5
UX: chat index flex issues (#29157) 2024-10-10 12:55:08 +02:00
chapoi
d58a2b853f
UX: fix missing text overflow ellipsis in chat index pages (#29150) 2024-10-10 09:57:32 +02:00
Sérgio Saquetim
08d5cf01cd
FIX: Don't override other sidebar panels when opening/closing the chat drawer (#29144)
This commit fixes an issue where the following happens:

1. The user opens a page where an alternative sidebar panel is displayed like /admin or other page where a plugin is displaying an alternative sidebar like the `docs-categories` plugin
2. Clicking the chat icon in the header and opening the drawer, or if you just minimize chat into drawer after it opens full-screen
3. The alternative sidebar panel is lost and reverted to the main panel.
2024-10-09 20:29:19 -03:00
Alan Guo Xiang Tan
ed6c9d1545
DEV: Call Discourse.redis.flushdb after the end of each test (#29117)
There have been too many flaky tests as a result of leaking state in
Redis so it is easier to resolve them by ensuring we flush Redis'
database.

Locally on my machine, calling `Discourse.redis.flushdb` takes around
0.1ms which means this change will have very little impact on test
runtimes.
2024-10-09 07:19:31 +08:00
Discourse Translator Bot
a4531be580
Update translations (#29123) 2024-10-08 20:21:43 +02:00
chapoi
d64d0ddd3d
UX: fix overflow on thread index pages (mobile) (#29126) 2024-10-08 15:27:41 +02:00
Joffrey JAFFEUX
268213a93c
FIX: adds post_quote as placeholder (#29083)
The script `send_chat_message` when used with the `post_created_edited` trigger now accepts `{{post_quote}}` as placeholder for the value of `message`.

This is made possible by a new method in `utils`. Usage:

```ruby
  placeholders["foo"] = utils.build_quote(post)
```
2024-10-08 21:55:11 +09:00
chapoi
0ba7a7ecab
UX: new sidebar styling (#29119) 2024-10-08 11:28:36 +02:00
David Battersby
a7a9148b1e
DEV: consolidate chat channel notification settings (#29080)
On the chat channel settings page, we want to show a single Send push notifications setting instead of the current Desktop notifications and Mobile push notifications settings.

For existing users, use the Mobile push notifications setting value for the new Send push notifications setting.
2024-10-08 13:13:01 +04:00
Loïc Guitaut
229773e7a8 DEV: Drop OpenStruct for the context object in services
While using `OpenStruct` is nice, it’s generally not a very good idea as
it usually leads to performance problems.

The `OpenStruct` source code even says basically to avoid it.

Since the context object is crucial in our services, this patch replaces
`OpenStruct` with a custom implementation instead.
2024-10-08 10:34:55 +02:00
Martin Brennan
85774cc214
UX: Automatically collapse admin page header buttons on mobile (#29040)
This commit attempts to improve the mobile experience for
admin page header and subheader by automatically collapsing
all action buttons in these components into a DMenu when viewing
mobile.

This is done by using different "list" wrapper components and a
DMenu trigger and a DropdownMenu on mobile only, and uses has-block
to determine whether to render the DMenu trigger at all.

This also removes the `PluginOutlet` in `AdminPluginConfigPage`, it
was too inflexible for this `DropdownMenu` case, and since the `:actions`
were always rendering we couldn't rely on `has-block`. A new plugin API,
`registerPluginHeaderActionComponent`, has been introduced instead to
replace it.
2024-10-08 08:28:32 +10:00
Alan Guo Xiang Tan
dc3c94961c
DEV: Fix flaky chat system tests (#29104)
`PageObjects::Pages::ChatThread#has_no_loading_skeleton?` was broken
because `.chat-thread__messages` is no longer a valid class.
2024-10-07 14:20:19 +08:00
chapoi
8d1867688f
UX: add padding bottom to chat index list (#29096) 2024-10-07 07:09:27 +02:00
Jan Cernik
1da97de7f0
SECURITY: Correctly parse URLs in chat excerpts 2024-10-07 11:48:41 +08:00
Penar Musaraj
d959bfdc61
UX: Improve bottom padding to chat index on mobile (#29086)
Minor adjustment to #29082
2024-10-04 11:33:38 -04:00
chapoi
c13ca6eb19
UX: chat index mini refactor (#29082) 2024-10-04 08:10:36 -04:00
David Battersby
9eaf908e63
DEV: cleanup chat desktop notification data (#28943)
Makes channel_id and is_direct_message_channel consistent across desktop notifications, which also removes the need to lookup the channel from Chat Notification Manager.
2024-10-03 12:43:17 +04:00
Loïc Guitaut
ad8f46f4f1 DEV: Make params explicit for services in controllers 2024-10-03 16:56:39 +09:00
Loïc Guitaut
fc1c5f6a8d DEV: Have contract take a block in services
Currently in services, the `contract` step is only used to define where
the contract will be called in the execution flow. Then, a `Contract`
class has to be defined with validations in it.

This patch allows the `contract` step to take a block containing
validations, attributes, etc. directly. No need to then open a
`Contract` class later in the service.

It also has a nice side effect, as it’s now easy to define multiples
contracts inside the same service. Before, we had the `class_name:`
option, but it wasn’t really useful as you had to redefine a complete
new contract class.
Now, when using a name for the contract other than `default`, a new
contract will be created automatically using the provided name.

Example:
```ruby
contract(:user) do
  attribute :user_id, :integer

  validates :user_id, presence: true
end
```
This will create a `UserContract` class and use it, also putting the
resulting contract in `context[:user_contract]`.
2024-10-02 17:00:01 +09:00
Discourse Translator Bot
76ad581f67 Update translations 2024-10-02 08:55:44 +02:00
Jarek Radosz
41c3c5745e
DEV: Fix optionalService in decorator form (#29042)
…and remove unused injections
2024-10-01 14:12:34 +02:00
Martin Brennan
73f42e110a
FIX: Unscoped plugin config page actions outlet (#29026)
In 61c1d35f17 I added a
PluginOutlet to AdminPluginConfigPage. This was intended to be
used as a way to render actions buttons inside the header of
a plugin that has a custom admin UI page. This worked, but
since the outlet was generically named, as soon as one plugin
used it the button would show on all plugins.

This fixes the immediate issue by naming the outlet based
on the plugin, then having each plugin specify their own
outlet to render into. There may be a nicer way to do this,
but for now this stops the bleeding.
2024-09-30 14:35:23 +10:00
Loïc Guitaut
afdb1ac0a0 DEV: Disallow default params in service steps
With the current implementation, a service step can be written as:
```ruby
def my_step(a_default_value: 2)
  …
end
```
That’s a pattern we want to avoid as default values (if needed) should
be probably defined in a contract.

This patch makes a service raise an exception if a default value is
encountered.
2024-09-19 14:47:55 +02:00
David Battersby
4bfe78d1e6
UX: remove alias from chat direct message channel titles (#28958)
Makes usernames in Chat Direct Message channels consistent with other areas of the app by removing the alias.
2024-09-18 22:18:46 +04:00
Loïc Guitaut
05b8ff436c DEV: Introduce a Service::ActionBase class for service actions
This will help to enforce a consistent pattern for creating service
actions.

This patch also namespaces actions and policies, making everything
related to a service available directly in
`app/services/<concept-name>`, making things more consistent at that
level too.
2024-09-18 17:02:46 +02:00
chapoi
9b383e3729
UX: chat composer style tweaks (#28938) 2024-09-18 02:45:44 +02:00
Joffrey JAFFEUX
2aca41914a
FEATURE: supports mark tag in chat messages (#28949)
This brings feature parity with posts where you can use this tag.
2024-09-17 20:52:34 +02:00
chapoi
0923f5e3a7
UX: small colour change to chat composer insert button (#28904) 2024-09-17 03:31:55 +02:00
David Battersby
b60f4606e5
FEATURE: allow names in chat channel title (#28843)
This change adds full names to direct message channel titles when the following conditions are met:

- SiteSetting.enable_names = true
- SiteSetting.display_name_on_posts = true
- SiteSetting.prioritize_username_in_ux = false

If a user's full name is blank, it will fallback to their username in both 1-1 channels and Group DM channels.
2024-09-16 18:12:13 +04:00
David Battersby
d7293eafef
DEV: add spec for chat drawer channel lists (#28927)
Adds a spec for chat channels lists in desktop drawer mode.
2024-09-16 12:15:21 +04:00
Kris
a914d3230b
DEV: remap all core icons for fontawesome 6 upgrade (#28715)
Followup to 7d8974d02f

Co-authored-by: David Taylor <david@taylorhq.com>
2024-09-13 16:50:52 +01:00
David Battersby
e9b7663798
UX: sort chat channels by activity in desktop drawer (#28822)
This change sorts the desktop chat channels by activity in drawer mode, and keeps sidebar channel list sorted by slug.
2024-09-13 10:14:37 +04:00
chapoi
b59056780c
UX: upodate stying of chat composer focused state (#28900) 2024-09-13 07:34:40 +02:00
Jarek Radosz
896f116443
DEV: Fix random typos (#28891) 2024-09-12 23:25:34 +02:00
Jarek Radosz
6bc9153a0d
DEV: Remove duplicated tests (#28889) 2024-09-12 23:20:49 +02:00
Jarek Radosz
4d484d89d0
DEV: Add a missing service injection (#28890) 2024-09-12 23:20:33 +02:00
Loïc Guitaut
b806dce13d DEV: Refactor suspend/silence user services
- fetch models inside services
- validate `user_id` in contracts
- use policy objects
- extract more logic to actions
- write specs for services and action
2024-09-12 10:28:48 +02:00
David Battersby
c697e70892
FIX: prevent chat channel not found ajax error (#28818)
On occasion we get an error popup on desktop due to the channel not being found.

This change means that we only check the cached channels in ChatChannelsManager for the matching channel id, but we skip doing manual lookup which results in ajax popup when it fails.
2024-09-10 11:52:25 +04:00
Martin Brennan
61c1d35f17
FEATURE: Convert chat plugin UI to new show plugin and admin UI guidelines (#28632)
This commit converts the current chat plugin UI into the
new "show plugin" UI already followed by AI and Gamification.

In the process, I also:

* Made a dedicated /new route to create new webhooks
* Converted the webhook form to FormKit
* Made some fixes and improvements to the `AdminPluginConfigPage`, `AdminPageHeader`,
   and `AdminPageSubheader` generic components, so more plugins can
   adopt the UI guidelines too. This includes adding a header outlet so plugins
   can add action buttons to the plugin show page header.
* Fixes the submit button loading state for FormKit (by Joffrey)

---------

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2024-09-10 15:16:16 +10:00
Kris
deb751dfe3
UX: remove btn-default class from chat thread tracking dropdown (#28789) 2024-09-06 15:14:29 -05:00
David Battersby
2a5e1aa8e6
FEATURE: only play chat sound when chat badge icon is shown (#28387)
Every time a desktop chat sound plays, there should be some visual cue as to why the sound was played in the first place.

This change follows the chat indicator preference:

- All New Messages - a blue dot is shown for all messages, so we attempt to play a sound every time
- Direct Messages, Mentions and Watched Threads - a green dot is shown for all urgent messages, so we attempt to play a sound for urgent chat notifications
- Only Mentions - only play chat sounds when user is mentioned
- Never - we never play chat sounds, as user wouldn’t know why the sound was played
2024-09-06 18:25:25 +04:00
David Battersby
a193bf4360
UX: update chat channel sorting (#28760)
Reverts chat channel sorting changes made in #28731 due to desktop sidebar.
2024-09-05 20:58:15 +04:00
Joffrey JAFFEUX
9b630c8cca
DEV: adds post_created_edited suport to chat (#28757) 2024-09-05 17:17:18 +02:00
David Battersby
b7cfd4e146
FIX: toggle chat drawer on channel thread list (#28759)
Chat toggle relies on using a height: auto to collapse drawer, however in channel threads we should be only displaying threads when drawer is expanded. Displaying threads conditionally based on drawer toggle status fixes this.
2024-09-05 19:01:12 +04:00
David Battersby
d5670069f5
UX: fix spacing of emoji in chat channel title (#28756)
Fixes a small spacing bug with emoji in channel titles
2024-09-05 16:43:06 +04:00
Joffrey JAFFEUX
81c5f1d75f
DEV: send_chat_message supports topic_tags_changed (#28755)
This will allow admins to use this script and trigger together.
2024-09-05 13:05:19 +02:00
David Battersby
e991574389
UX: chat drawer increase unread channel visibility (#28731)
This change increases the visibility of unread channels to make them stand out more in drawer mode (desktop).

When a channel is unread:

- it floats to the top;
- when multiple channels are unread, they are sorted alphabetically (equal to how it’s done on mobile)
- the unread indicator blue dot moves to directly right of the channel name
2024-09-05 13:36:50 +04:00
Loïc Guitaut
e94707acdf DEV: Drop WithServiceHelper
This patch removes the `with_service` helper from the code base.
Instead, we can pass a block with actions directly to the `.call` method
of a service.

This simplifies how to use services:
- use `.call` without a block to run the service and get its result
  object.
- use `.call` with a block of actions to run the service and execute
  arbitrary code depending on the service outcome.

It also means a service is now “self-contained” and can be used anywhere
without having to include a helper or whatever.
2024-09-05 09:58:20 +02:00
Osama Sayegh
a23773f83d
DEV: Deprecate show_in_ui argument of the register_stat API (#28727)
We need to start printing deprecation notices when the `show_in_ui` argument is used because it works only for the old about page which will be removed soon. For the new about page, we've introduced a new API `addAboutPageActivity` which is more flexible than a true/false argument on the server side.

Internal topic: t/136551.
2024-09-04 19:58:14 +03:00
David Battersby
a2f625a0ef
DEV: remove CSS for consolidated DM notifications (#28728)
Removes unused CSS that was a temporary fix for a new notification type that was later reverted.
2024-09-04 11:39:49 +04:00
David Battersby
fdcf4698fc
UX: Update Chat Group Name and Placeholder (#28703)
* UX: Update Chat Group Name and Placeholder

* update tests

* fix failing tests

* better checking of system user when setting dm title
2024-09-04 15:52:23 +10:00
Osama Sayegh
280adda09c
FEATURE: Support designating multiple groups as mods on category (#28655)
Currently, categories support designating only 1 group as a moderation group on the category. This commit removes the one group limitation and makes it possible to designate multiple groups as mods on a category.

Internal topic: t/124648.
2024-09-04 04:38:46 +03:00
Discourse Translator Bot
0171eb0c94
Update translations (#28705) 2024-09-03 11:46:50 -04:00
Krzysztof Kotlarek
7577231ba2
DEV: the ability to define setting areas (#28570)
A new setting attribute is used to define the areas (separated by `|`).

In addition, endpoint `/admin/config/site_settings.json` accepts new `filter_area` data.
2024-09-03 09:25:45 +10:00
Discourse Translator Bot
b1e539c1b9
Update translations (#28682) 2024-09-02 18:00:43 +02:00
David Battersby
997fbc9757
FEATURE: Add ability to watch chat threads (#28639)
This change introduces a new thread notification level allowing users to get notified when someone replies to the thread.

Users who watch a thread will get a green notification on the chat icon and a user notification (blue). User notifications are consolidated based on thread id to prevent cluttering the original users notification area.

---------

Co-authored-by: Régis Hanol <regis@hanol.fr>
2024-09-02 16:45:55 +04:00
David Taylor
583c932173
DEV: Refactor complex initializers into classes (#28661)
We're working to remove all decorators from object-literal-properties. This commit refactors all initializers which were using these decorators into classes, where decorators are allowed. Also adds cleanup logic to the local-dates initializer, which was previously missing.
2024-09-02 10:08:07 +01:00
Discourse Translator Bot
68c9553251
Update translations (#28577) 2024-08-29 15:37:52 -04:00
David Taylor
ed4f80d589
FIX: Chat emoji picker positioning (#28643)
Removes chat-specific changes from dfc947a97d, and adds `preventScroll: true` to prevent timing issues between the emoji picker being brought into the viewport and being focussed.
2024-08-29 17:00:26 +01:00
Renato Atilio
54d6e52607
FIX: chat mailer log noise (#28616)
Fixes the log noise caused by a deprecation notice
2024-08-29 11:39:08 -03:00
David Taylor
a2cab9a342
DEV: Update remaining core plugin components to native-class syntax (#28611)
Changes made using the ember-native-class-codemod, plus some manual tweaks
2024-08-29 12:16:52 +01:00
Loïc Guitaut
d26d45540e DEV: Use run_successfully matcher in service specs 2024-08-28 16:30:09 +02:00
Jan Cernik
a12b933f5c
UX: highlight the chat channel/DM only when chat is expanded (#28488) 2024-08-27 09:50:36 -03:00
Joffrey JAFFEUX
b4a8873596
DEV: changes identifier from card to usercard (#28575) 2024-08-27 14:08:49 +02:00
Alan Guo Xiang Tan
82e75c8700
DEV: Migrate Chat::NotificationMention#notification_id to bigint (#28571)
`Notification#id` was migrated to `bigint` in 799a45a291
2024-08-27 14:57:16 +03:00
David Battersby
910bfaf5f5
FIX: prevent desktop notification callbacks on mobile (#28527) 2024-08-26 15:49:49 +10:00
David Taylor
fe6c91daa3
DEV: Convert select-kit subclasses to native class syntax (#28491)
This covers all select-kit subclasses in core and core plugins

Followup to https://github.com/discourse/discourse/pull/28489
2024-08-23 13:19:26 +01:00
Joffrey JAFFEUX
842d2749a1
FIX: adds chat-draw-expanded class to body (#28490)
To achieve this, the code is now using bodyClass instead of relying on the addChatDrawerStateCallback`.
2024-08-22 17:46:41 +02:00
Loïc Guitaut
f11f2b983f DEV: Put back the model step in HandleCategoryUpdated service
Now that `ActiveRecord` relations are properly handled in a `model`
step, putting this step back will allow the service to stops its
execution if there are no users to be removed without calling the pretty
big SQL query contained in the `CalculateMembershipsForRemoval` action.
2024-08-22 12:33:58 +02:00
Régis Hanol
4b49e358fb
FIX: skip 1:1s when chat search returns users (#28464)
When we use CTRL/CMD + K to search, on the server we run 4 queries:

- 1 for users
- 1 for groups
- 1 for category channels
- 1 for direct message channels

The server returns up to 10 results per type and the client concatenate all the results (in the order I described) and then takes the first 10 or so.

Let's say you've had 1:1s with john1, john2, and john3. Searching for “john” would return all the johns as “users”. It doesn’t make sense to also return them as 1:1 dms.

That’s what this fixes. When the search returns some users, we skip all 1:1s because we assume they will show up as the results of the “users” query.

We’ll always return matching direct messages with more than 2 users (aka. “group chats”). All 3 other queries (users, groups, and category channels) are unaffected.

Internal ref - t/136079
2024-08-22 11:35:13 +02:00
Loïc Guitaut
0636855706 DEV: Allow using an AR relation as a model in services
This patch allows using an AR relation as a model in services without
fetching associated records. It will just check if the relation is empty
or not. In the former case, the execution will stop at that point, as
expected.
2024-08-20 16:32:46 +02:00
Osama Sayegh
db6eff7be9
DEV: Allow custom site activity items in the new /about page (#28400)
This commit introduces a new frontend API to add custom items to the "Site activity" section in the new /about page. The new API is called `addAboutPageActivity` and it works along side the `register_stat` serve-side API which serializes the data that the frontend API consumes. More details of how the two APIs work together is in the JSDoc comment above the API function definition.

Internal topic: t/128545/9.
2024-08-20 16:16:05 +03:00
Joffrey JAFFEUX
ccb1861ada
DEV: better highlighting of mentions (#28403)
This commit improves the hilight-ing of mentions in posts and chat messages.

- `@here` and `@all` will generate a `<a class="mention --wide">`
- bots will generate a `<a class="mention --bot">`
- current user will generate a `<a class="mention --current">`

To achieve this change the following value transformer has been added: "mentions-class". It will be run in posts and chat messages after the mention is rendered.

A bug were bots were not considered in mentioned users has also been fixed as part of this PR.
2024-08-20 14:37:28 +02:00
David Taylor
dfc947a97d
PERF: Defer button actions to improve interaction-next-paint (INP) (#28019)
This is a variation on bc3e8a9963cf9a64d114ec751c875025af169690, which was reverted due to issues on iOS. Safari's "in response to user action" check cannot follow the `runAfterFramePaint` chain of interaction -> requestAnimationFrame -> messageChannel, and so some sensitive browser APIs (e.g. clipboard, upload, etc.) were blocked.

This commit is similar, but uses `next()` instead of `runAfterFramePaint()`. The result seems the same, but doesn't have the same issue on iOS.

The chat-emoji-picker change was required to resolve a test failure. The emoji picker has never closed-on-scroll on desktop, so there is no user-facing change in behavior.
2024-08-20 10:11:34 +08:00
Sam
ade001604b
PERF: automatically join users to channels more efficiently (#28392)
- Only ever auto join 10k users to channels (ordered by last seen)
- Join users to all channels at once, instead of batching and splitting
2024-08-16 13:58:12 +10:00
Alan Guo Xiang Tan
de79e5628e
PERF: Reduce mem allocation of Chat::AutoRemove::HandleCategoryUpdated (#28393)
This is a follow-up to 671f40ce07 and
ed11ee9d05.

While the optimisations in the previous commits were sound, it did not
resolve the memory bloat we were seeing. It turns out that we call
`.blank?` on the model's result if the model has not been marked
optional. The problem with this is that if the model returns an
ActiveRecord relation, calling `.blank?` on the relation basically loads
everything into memory.

Therefore, this commit removes `users` as a model in the  since it really isn't
a model but just a relation.
2024-08-16 11:35:08 +08:00