Commit Graph

3290 Commits

Author SHA1 Message Date
Joffrey JAFFEUX 22237e4407
FIX: set active thread on correct channel (#27141)
activeChannel is something we should use less and less as it could not exist, in this case we have the channel right here in the function so there's no reason to reach for `this.chat.activeChannel`.
2024-05-22 23:38:12 +02:00
Joffrey JAFFEUX 485427b578
FIX: correctly handles near-message-with-thread route in drawer (#27115)
Prior to this fix we wouldn't intercept it, and we also wouldn't handle it, which in result would cause us to handle as a full page interaction and open the full page chat even if you were in drawer mode.
2024-05-22 21:03:40 +02:00
Régis Hanol 0012d9626f FIX: chat activity indicator wasn't working for threads
When a user had the chat option "Show activity indicator in header" set to "all new messages", and they would get a reply to a thread they're part of, the chat icon in the header would not show the unread bubble indicator.

In order to fix this, the `ChatHeaderIconUnreadIndicator` component will now `showUnreadIndicator` whenever there is either one unread public channel or there are unread threads.

I only added a system spec for this very specific path because I don't want to slow down the whole suite to test for all the various combination of the `chat_header_indicator_preference` values.

Internal ref - t/128874
2024-05-22 17:42:59 +02:00
Régis Hanol d4af30f26d FIX: elided content in email should always have an href
Not 100% sure why the changes in `PrettyText.format_for_email` raised this issue, but we were missing adding a link to the Discourse instance whenever we are replacing the elided part of a post with a link to either the post or the Discourse instance in the email.

Also reformated the specs using better variable names (sometimes a variable named `md` would contain some html) and used the `match_html` helper for all the tests.
2024-05-22 15:38:18 +02:00
Jan Cernik 9889547475
FEATURE: Allow to bulk delete chat messages (#26586) 2024-05-22 08:57:00 -03:00
Joffrey JAFFEUX e5d040ef61
UX: removes blinking indicator while streaming message (#27131)
Given this is currently buggy and  we have the cancel button Im not sure this is actually necessary. I feel like it's adding a lot of noise of low value.

For now at least, it's better without it.
2024-05-22 13:48:44 +02:00
Joffrey JAFFEUX 52125d849f
FIX: correctly check for disabled notifications, tab and is idle (#27127)
This commit reuses the existing codepath in desktop-notifications and make it available to use to chat.

primaryTab was too hard to test if not impossible in this service test, however isIdle and disabled notifications are correctly tested.
2024-05-22 10:08:05 +02:00
Jan Cernik 915982955b
DEV: Fix flaky spec when creating a chat message from params (#27099) 2024-05-21 17:39:17 -03:00
Joffrey JAFFEUX bc0ef9f7ee
FIX: play audio sound on message in non group DMs (#27112)
Prior to this change, only mentions would get a notification and a sound. This change will not create a notification for this case, but will play a sound. This is still respecting notification settings, not playing the sound when you are viewing the channel or not following it.

---------

Co-authored-by: Régis Hanol <regis@hanol.fr>
2024-05-21 21:51:22 +02:00
Discourse Translator Bot db3db06caf
Update translations (#27104) 2024-05-21 17:40:50 +02:00
Jarek Radosz 87769a83c4
DEV: Implement glimmer topic-list (#26743)
(experimental)

The initial implementation of glimmer topic-list and related components. Does not include new APIs and isn't compatible with existing customization. That's gonna come in future PRs.

Enabled by adding groups to `experimental_glimmer_topic_list_groups` setting.
2024-05-21 14:36:15 +02:00
Krzysztof Kotlarek 40d65dddf8
Revert "DEV: move post flags into database (#26951)" (#27102)
This reverts commit 7aff9806eb.
2024-05-21 16:21:07 +10:00
Krzysztof Kotlarek 7aff9806eb
DEV: move post flags into database (#26951)
This is preparation for a feature that will allow admins to define their custom flags. Current behaviour should stay untouched.
2024-05-21 13:15:32 +10:00
Joffrey JAFFEUX 7a0c4c5296
FIX: improves chat audio notification reliability (#27089)
Debouncing the audio was causing the audio to be lost sometimes, somewhat randomly. It's not supposed to be necessary.

The commit also refactors the code to async/await.
2024-05-20 20:48:30 +02:00
Joffrey JAFFEUX 9302187ca4
FIX: ensures topic info is dynamic with scroll (#27082)
Prior to this fix we were using `topic.current_post_number` which is coming from the server side and represents the initial topic scroll position when initially rendered to the end user. However, this value is not dynamic and is not updated when the user scrolls, `topic.currentPost` is the dynamic equivalent.

No test as there are very low chances a test like this one based on scroll position, will be reliable over time.
2024-05-20 11:20:37 +02:00
Régis Hanol aa1b874f1a
FIX: My Thread's last reply excerpt on mobile (#27072)
... wasn't properly escaped so it would should html entities (like `&#39;` instead of the apostrophe `'`).

I checked all the other places we show an excerpt and this was the only one that was missing the call to `htmlSafe` -> `replaceEmoji`.

Internal ref - t/128877
2024-05-18 14:07:49 +02:00
Régis Hanol 6060e4618c
FIX: customize chat dropdown labels (#27067)
The translations of the labels of some of the chat preferences dropdowns were not customizable via the "site texts" feature.

This was because they were declared outside of a Controller class and were thus not taking into account the customization through "site texts".

Internal ref - t/128859
2024-05-17 18:56:08 +02:00
David Battersby 34c4acd32f
DEV: update thread title prompt migration (#27052)
Add migration to handle batch processing of user options 

Co-authored-by: Osama Sayegh <asooomaasoooma90@gmail.com>
2024-05-17 00:53:19 +04:00
Régis Hanol 02469d5795
FIX: chat replies are not always in a thread (#27023)
When you reply to a chat message, we [always create a thread][1]. But when the channel we're in doesn't have threading enabled, the reply is _technically_ not a thread.

This changes the `in_thread?` method to check for both the presence of a `thread_id` and to ensure that the channel has `threading_enabled`.

Internal ref - t/128103/3

[1]: e6e3eaf472/plugins/chat/app/services/chat/create_message.rb (L110-L115)
2024-05-16 16:10:23 +02:00
Jan Cernik 0258e985d8
DEV: Remove legacy styles for LazyYT (#27047) 2024-05-16 09:53:59 -03:00
Sam e90e6e8f86
FIX: thread safety for active automation tracking (#27044) 2024-05-16 13:34:24 +10:00
Jarek Radosz 24c55d6797
FIX: Sidebar mode switching on subfolder (#27026) 2024-05-15 10:12:15 +02:00
Régis Hanol 906f48694c FIX: deep linking to a message in a thread
Whenever you get a bookmark notification, a mention notification, or click on a bookmark on a message in a long thread, we should ensure we always highlight and show the proper message.

Before this fix, we would correctly load the thread, but would always start at the bottom.

Internal ref. t/128103
2024-05-15 09:42:12 +02:00
Discourse Translator Bot 104ca5c325
Update translations (#27017) 2024-05-14 16:19:44 +02:00
chapoi 49602905d3
UX: add missing class for oneboxing youtube video (#27005) 2024-05-13 22:53:03 +02:00
Martin Brennan 10b2715cb3
DEV: Use site setting mandatory_values for chat allowed groups (#26994)
For both `chat_allowed_groups` and `chat_message_flag_allowed_groups`,
this commit removes the `is_staff?` guardian check, and instead
adds both `moderators` and `admins` auto groups as `mandatory_values`
to those settings, as part of an ongoing effort to do this for
group-based setting values.
2024-05-13 14:38:26 +10:00
Jarek Radosz fcd2293226
DEV: Convert the entire sidebar to gjs (#26978) 2024-05-12 19:43:51 +02:00
Osama Sayegh 3be4924b99
DEV: Move array type custom fields to JSON type in automation (#26939)
The automation plugin has 4 custom field types that are array typed. However, array typed custom fields are deprecated and should be migrated to JSON type.

This commit does a couple of things:

1. Migrate all four custom fields to JSON
2. Fix a couple of small bugs that have been discovered while migrating the custom fields to JSON (see the comments on this commit's PR for details https://github.com/discourse/discourse/pull/26939)
2024-05-10 18:47:12 +03:00
Osama Sayegh 9ebf7c9c37
FIX: Preveint recurring automations from running before `start_date` (#26963)
Some combinations of start_date and frequency/interval values can cause a recurring automation rule to either trigger before its start_date or never trigger. Example repros:

- Configure a recurring automation with hourly recurrence and a start_date several days ahead. What this will do is make the automation start running hourly immediately even though the start_date is several days ahead.

-  Configure a recurring automation with a weekly recurrence and a start_date several weeks ahead. This will result in the automation never triggering even after the start_date.

These 2 scenarios share the same cause which is that the automation plugin doesn't use the start_date as the date for the first run and instead uses the frequency/interval values from the current time to calculate the first run date.

This PR fixes this bug by adding an explicit check for start_date and using it as the first run's date if it's ahead of the current time.
2024-05-10 11:45:23 +10:00
Joffrey JAFFEUX 72aed56daf
DEV: bots are always allowed to chat (#26948)
Bots should be allowed to chat regardless of their groups, just like staff. It makes configuring bots to work in chat much easier.
2024-05-09 12:05:31 +02:00
David Battersby 4404b6808c
UX: expand threads list tap area on mobile (#26818)
This change adds a wrapper link around the thread list details on mobile to make the click area larger.

We also update child div elements to span to ensure valid html, since the link is an inline element and divs are block level.

---------

Co-authored-by: chapoi <101828855+chapoi@users.noreply.github.com>
2024-05-09 12:45:02 +04:00
Jarek Radosz e579cfc08f
DEV: Avoid using the old action helper (#26935) 2024-05-08 20:26:48 +02:00
Joffrey JAFFEUX c8faf3e427
FIX: ensures chat notifications links work with subfolder (#26938)
We were missing two `getURL` calls.

The test is now written for subfolder but it's good enough. If it's working for subfolder, it's working for non subfolders, the opposite being false.
2024-05-08 14:47:15 +02:00
Joffrey JAFFEUX fe16633a0c
DEV: allows for multiple menus/tooltips (#26823)
menus and tooltips are now appended to their own portals. The service are the only responsible for managing the instances, prior to this commit, services could manage one instance, but the DMenu and DTooltip components could also take over which could cause unexpected states.

This change also allows nested menus/tooltips.

Other notable changes:

- few months ago core copied the CloseOnClickOutside modifier of float-kit without removing the float-kit one, this commit now only use the core one.
- the close function is now trully async
- the close function accepts an instance or an identifier as parameter
2024-05-07 23:48:44 +02:00
Régis Hanol 12cba2ce24 PERF: bail out of expensive post validations
Whenever a post already failed "lightweight" validations, we skip all the expensive validations (that cooks the post or run SQL queries) so that we reply as soon as possible.

Also skip validating polls when there's no "[/poll]" in the raw.

Internal ref - t/115890
2024-05-07 18:56:16 +02:00
Joffrey JAFFEUX 278eb0a1a5
FIX: improvements to chat message streaming (#26892)
- prevents re-rendering avatars while updating messages quickly in the thread preview indicator
- ensures the cancel button is shown when you are admin OR when the streamed message is a reply to the current user
2024-05-07 15:38:24 +02:00
Discourse Translator Bot 42297b2ec3
Update translations (#26903) 2024-05-07 09:31:46 -04:00
Joffrey JAFFEUX 26c8eab1f3
FIX: allows bots to create/update/stream messages (#26900)
Prior to this commit, only system users had this pass.

Another significant change of the PR, is to make membership of a channel the angular stone of the permission check to create/update/stop streaming a message. The idea being, if you are a member of a channel already we don't need to check if you can join it AGAIN.

We also have `Chat::AutoRemove::HandleCategoryUpdated` which will deal with permissions change so it's simpler and less prone to error to consider the membership as the only source of truth.
2024-05-07 15:17:42 +02:00
Joffrey JAFFEUX 2347ff7074
FIX: only show discourse-ai CTA to admins (#26895) 2024-05-07 00:43:30 +02:00
Osama Sayegh 2f2355b0ad
DEV: Convert some files to autoloading and various improvements (#26860) 2024-05-06 23:12:55 +03:00
chapoi 8bbcd409e3
UX: hide user count in original message link (#26890) 2024-05-06 22:02:15 +02:00
Jarek Radosz 79870d3a1e
DEV: Fix random typos (#26881) 2024-05-06 20:52:48 +02:00
Joffrey JAFFEUX f72f63660a
FIX: an existing member of a channel is allowed to join (#26884)
There's no point checking if a user can join a channel if they are already part of it. This case was frequent when using `enforce_membership: true` for custom bots for example.
2024-05-06 17:14:20 +02:00
Joffrey JAFFEUX 00d88766b2
FIX: correctly pass topic/posts context (#26882)
This case had not been tested end to end as `Discourse.track_events` was not working when wrapping `send_message`. Because of this lack of end to end test, a regression has been created when renaming the expected context properties. This commit fixes the regression and write a slightly convulted, but effective end to end test.
2024-05-06 15:33:00 +02:00
Régis Hanol 6c6a56139e FIX: nested polls
Polls should work when "nested" inside a quote or a details block.

Internal ref - t/89085
2024-05-03 19:46:13 +02:00
Joffrey JAFFEUX 671e6066bf
DEV: adds first_messages/last_messages to thread SDK (#26861)
This commit introduces several enhancements to the ChatSDK module, aiming to improve the functionality and usability of chat thread interactions. Here's what has been changed and added:

1. **New Method: `first_messages`:**
   - Added a method to retrieve the first set of messages from a specified chat thread.
   - This method is particularly useful for fetching initial messages when entering a chat thread.
   - Parameters include `thread_id`, `guardian`, and an optional `page_size` which defaults to 10.
   - Usage example added to demonstrate fetching the first 15 messages from a thread.

2. **New Method: `last_messages`:**
   - Added a method to retrieve the last set of messages from a specified chat thread.
   - This method supports reverse pagination, where the user may want to see the most recent messages first.
   - Similar to `first_messages`, it accepts `thread_id`, `guardian`, and an optional `page_size` parameter, defaulting to 10.
   - Usage example provided to illustrate fetching the last 20 messages from a thread.
2024-05-03 17:30:39 +02:00
David Taylor f28742e597
DEV: Update chat scheduled job loading to match skeleton (#26853)
Followup to e949684fc5, ref https://github.com/discourse/discourse-plugin-skeleton/pull/47
2024-05-02 19:20:00 +01:00
David Taylor e949684fc5
DEV: Eager load chat's scheduled jobs in development mode (#26852) 2024-05-02 18:26:30 +01:00
Joffrey JAFFEUX dda4bb0f7c
DEV: allows to disable strip_whitespaces in messages (#26848)
The TextCleaner step has been moved from chat message’s validation to create_message/update_message services. It allows us to easily tweak part of its behavior depending on the needs.

For example we will now disable strip_whitespaces by default when streaming messages as we want to keep newlines and spaces at the end of the message.
2024-05-02 11:59:18 +02:00
David Battersby c1f6ec5f62
FIX: add excerpt fallback for chat message replies (#26834) 2024-05-01 16:39:47 +02:00