Commit Graph

2465 Commits

Author SHA1 Message Date
Jan Cernik 585a2e4e77
FEATURE: Use rich user status tooltip everywhere (#21125)
- Inline mentions on posts
- Inline mentions on chat messages
- The user autocomplete for the composer
- The user autocomplete for chat
- The chat section of the sidebar
2023-07-03 11:09:41 -03:00
Jan Cernik 5034eda386
FIX: Allow to use `%h%m%s` for youtube `t` param (#22299) 2023-07-03 10:39:37 -03:00
David Taylor b3a23bd9d6
DEV: Introduce new component-based DModal API (#21304)
Ember 4.x will be removing the 'named outlet' feature, which were previously relying on to render modal 'controllers' and their associated templates. This commit updates the modal.show API to accept a component class, and also introduces a declarative API which can be used by including the <DModal component directly in your template.

For more information on the API design, and conversion instructions from the current API, see these Meta topics:

DModal API: https://meta.discourse.org/t/268304
Conversion: https://meta.discourse.org/t/268057
2023-07-03 10:51:27 +01:00
Martin Brennan f6072ba804
DEV: Move user count update for channels to ensure_consistency! (#22321)
This fixes a longstanding TODO to move the contents of the
UpdateUserCountsForChannels job to the ensure_consistency!
method of Chat::Channel, which runs every 15 mins as part of
periodical updates.

This commit also addresses the performance issue of the original,
where we would fetch all channels and do an individual query to
get the count and update the count of each one. Now we do it all
in one query, and only publish the changed channels to the UI.
2023-07-03 11:41:51 +10:00
Martin Brennan 821cf201f5
FIX: ActiveModel::Types :array load error in production (#22377)
Followup to 3f1024de76

The ActiveModel::Types.register(:array) call for chat was
called too late in the Zeitwerk load order in production,
causing this error:

> `lookup': Unknown type :array (ArgumentError)
> raise ArgumentError, "Unknown type #{symbol.inspect}"
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

We need to load the type and register it manually before the rest
of the chat files are loaded via the engine and Zeitwerk.
2023-07-03 11:30:09 +10:00
Martin Brennan 3f1024de76
DEV: Refactor DM channel creation into new service pattern (#22144)
This will be used when we move the channel creation for DMs
to happen when we first send a message in a DM channel to avoid
a double-request. For now we can just have a new API endpoint
for creating this that the existing frontend code can use,
that uses the new service pattern.

This also uses the new policy pattern for services where the policy
can be defined in a class so a more dynamic reason for the policy
failing can be sent to the controller.

Co-authored-by: Loïc Guitaut <loic@discourse.org>
2023-07-03 10:18:37 +10:00
Martin Brennan 58a3cdc6ae
DEV: Try fix flaky chat navigation spec (#22356)
Followup to e57070af92,
try to check for href of link first before clicking.
2023-06-30 09:08:29 +08:00
Alan Guo Xiang Tan e57070af92
DEV: Skip a flaky system test (#22354)
This has been flagged by our internal system as well and has been
failing on CI. Skip this for now to improve the stability of our system
test runs while we figure out why it is flaky.
2023-06-30 07:35:44 +08:00
Joffrey JAFFEUX ea0b8ca38c
FEATURE: allows to enable/disable threading in UI (#22307)
Enabling/Disabling threading has been possible through command line until now. This commit introduces two new UIs:

- When creating a channel, it will be available once the category has been selected
- On the settings page of a channel for admins
2023-06-29 07:19:12 +02:00
Martin Brennan 1194ed10e1
FEATURE: Track last_viewed_at datetime for channel members (#22294)
Whenever a user opens a channel or marks it read, we now
update the last_viewed_at datetime for that channel membership
record. This is so we will be able to show thread unread indicators
in the channel sidebar that clear independently of the main thread
unread indicators. This unread functionality will follow in another
PR.
2023-06-29 09:22:17 +10:00
Martin Brennan 58c14ba0f9
DEV: Remove AJAX usage in chat-channel model (#22320)
Addressing TODO about using chatApi in the ChatChannel model,
but since it's a model we cannot easily use the chatApi service.
The model function is only called in one place so we may as well
just move the call there since the component can use chatApi
2023-06-29 09:21:28 +10:00
Martin Brennan 58c8f91d9a
DEV: Use same excerpt everywhere in chat (#22319)
Followup to c6b43ce68b

We can just use the rich excerpt everywhere since we know
we don't need text_entities -- that introduced security issues
just to fix a spec.
2023-06-29 09:20:20 +10:00
David Taylor ed70b16db6
DEV: Resolve poll plugin deprecation (#22330)
When using native class syntax, `observes` must be imported from `@ember-decorators/object`
2023-06-28 17:53:45 +01:00
Jarek Radosz 7791bb1276
DEV: Update moment-timezone-with-data (#22313)
`Africa/Cairo` timezone introduced DST so I replaced it in tests with `America/Lima`
2023-06-28 11:33:55 +02:00
Martin Brennan ccdc0822a8
DEV: Fix flaky thread navigation spec (#22323)
Introduced in cec68b3e2c,
this is flaky because if you click the back button before
the route is fully transitioned to the loaded thread,
we end up going to the history _before_ the thread list,
which ends up being the channel.

We need to make sure that everything is loaded for the
thread first, meaning the skeleton is not there.

Also exclude some noise from the capybara logs (image load failures)
2023-06-28 17:20:05 +10:00
Martin Brennan c4c566846d
DEV: Get rid of old chat TODOs (#22324)
These are all well-known things we need to deal with
(e.g. scrolling and granular read in thread panel) or just
unnecessary to keep around.
2023-06-28 17:16:03 +10:00
Martin Brennan 41ebbab4ff
FIX: Chat threads N1 (#22322)
Followup to 1526d1f97d

This commit fixes an N1 for mentions/user status
when querying chat threads. This only happened if
any of the thread OMs had mentions.
2023-06-28 15:41:51 +10:00
Martin Brennan 1526d1f97d
FEATURE: Sort thread list by unread threads first (#22272)
* FEATURE: Sort thread list by unread threads first

This commit changes the thread list to show the threads that
have unread messages at the top of the list sorted by the
last reply date + time, then all other threads sorted by
last reply date + time.

This also fixes some issues by removing the last_reply
relationship on the thread, which did not work for complex
querying scenarios because its order would be discarded.

* FIX: Various fixes for thread list loading

* Use the channel.threadsManager and find the channel first rather
  than use activeChannel in the threads manager, otherwise we may
  be looking at differenct channels.
* Look at threadsManager directly instead of storing result for threads
  list otherwise it can get out of sync because of replace: true in
  other places we are loading threads into the store.
* Fix sorting for thread.last_reply, needed a resort.
2023-06-28 13:14:01 +10:00
Martin Brennan cec68b3e2c
FEATURE: Conditionally change back button route for thread (#22129)
When clicking back from a thread, we want to either go back to the
channel if the thread was opened from an indicator, or to the thread
list if we opened it from there. Since ember doesn't give a nice way
to get the previous route, we need to store this ourselves. We only
do this on mobile, on desktop we just follow existing behaviour.

Also implements a chat router history.

---------

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2023-06-28 09:58:47 +10:00
Jarek Radosz a6bd3994f3
UX: Align chat separators, increase mobile chat width (#22298) 2023-06-27 18:49:45 +02:00
Roman Rizzi f4e7a80600
DEV: Cache summarization strategy results. (#22230)
Updates the interface for implementing summarization strategies and adds a cache layer to summarize topics once.

The cache stores the final summary and each chunk used to build it, which will be useful when we have to extend or rebuild it.
2023-06-27 11:44:34 -03:00
Discourse Translator Bot a909dffe8f
Update translations (#22300) 2023-06-27 16:39:27 +02:00
Natalie Tay 1384ba5a4e
FIX: Cater for polls that can have multiple votes per user (#22297)
Cater for polls that can have multiple votes per user.

This fixes an older UserMerge and migration which was intended to
de-duplicate poll votes but did not account for "multiple" type polls.
2023-06-27 18:58:16 +08:00
chapoi 2548b819be
UX: add max-width to thread indicator (#22282) 2023-06-27 09:30:15 +02:00
Loïc Guitaut 885ab9a015
DEV: Introduce an `array` type for Chat contracts (#22278)
This small patch registers a new `ActiveModel` type: `array`.
It will split a string on `,` to create a new array. If the value is
already an array, nothing will happen and for all other types, it will
wrap the value in an array.

Here’s an example on an existing contract:
```ruby
  attribute :target_usernames

  before_validation do
    self.target_usernames =
      (
        if target_usernames.is_a?(String)
          target_usernames.split(",")
        else
          target_usernames
        end
      )
  end

  # can be rewritten as:

  attribute :target_usernames, :array
```
2023-06-27 10:51:58 +10:00
Joffrey JAFFEUX 0ab572fbf0
FIX: longer touch for active message (#22279)
Moving from 50ms to 125ms, it should limit cases where message is activated during scroll.
2023-06-26 16:59:10 +02:00
chapoi 802fb3b194
UX: chat message thread indicator improvements (#22224)
- gridified the thread message indicator, alleviating some problems with positioning and overflow
participant avatars will overlap/smush on smaller size and mobile
- the excerpt went from 3 > 2 lines of wrapping on smaller size, still 1 line on large size
- dropped the copy of "last reply"
- fixed wrong line height
- moved the "x replies" over to the right near the participants, as that makes more sense
- using a bubble to indicate other participants, instead of copy

This PR introduces the @container query, which is experimental. Nothing will break when it's being viewed in a not-supported browser, but it will be less elegant.
2023-06-26 14:47:13 +02:00
Loïc Guitaut 0f4beab0fb DEV: Update the rubocop-discourse gem
This enables cops related to RSpec `subject`.

See https://github.com/discourse/rubocop-discourse/pull/32
2023-06-26 11:41:52 +02:00
Alan Guo Xiang Tan 8e1d049e6b
DEV: Skip flaky chat system tests (#22275)
The skipped tests are flaky even when running locally. This is being
tracked internally and will be unskipped once it is fixed.
2023-06-26 16:52:09 +08:00
Kris 6ec95fa79c
FIX: sidebar dot color when chat is off (#22264) 2023-06-26 10:43:35 +02:00
chapoi a2a31eb420
UX: adding max height to image in chat blockquote (#22255)
* UX: adding max height to  blockquote image in chat
2023-06-23 10:33:12 +02:00
Jarek Radosz ba62d20f71
DEV: Update ember-template-lint (#22242) 2023-06-22 22:54:46 +02:00
Jarek Radosz 876ff17cc2
DEV: Update eslint/prettier (#22226) 2023-06-21 20:59:03 +02:00
Blake Erickson 1948063f9f
DEV: Cleanup unused chat route (#22231)
The `chat/chat#update_user_last_read` route no longer has corresponding
controller action so we should remove it.
2023-06-21 12:45:28 -06:00
Andrei Prigorshnev 3ea31f443c
FEATURE: Export chat messages to CSV file (#22113)
To export chat messages, go to `/admin/plugins/chat` and click the Create export 
button in the _Export chat messages_ section. You'll receive a direct message 
when the export is finished.

Currently, this exports all messages from the last 6 months, but not more than 
10000 messages.

This exports all chat messages, including messages from private channels and 
users' direct conversations. This also exports messages that were deleted.
2023-06-21 16:13:36 +04:00
Joffrey JAFFEUX 720c0c6e4d
UX: adds small delay before making message active (#22221)
This should prevent the message to show as active on mobile when making a touch to start scrolling.

This commit also makes naming of touch lifecycle functions coherent.
2023-06-21 13:07:12 +02:00
Andrei Prigorshnev f4add0ef6a
DEV: store user ids for different types of notifications in different hashes (#22049)
We had a bug in this code recently, sometimes users saw weird notifications 
like:

User mentioned all_mentioned_user_ids in the help chat channel

We fixed that bug in b85d057.

This refactoring is a follow-up to that fix. As that bug showed, it’s quite easy 
to introduce a key that may end up being sent to the `NotifyMentioned` job, 
which can lead to such weird notifications. This refactoring makes sure that 
the `to_notify` hash contains only IDs of users that should be notified about 
mentions.
2023-06-20 20:47:00 +04:00
Discourse Translator Bot a4594b925b
Update translations (#22204) 2023-06-20 17:27:36 +02:00
Jan Cernik e51bbfa4e8
FEATURE: Scroll to first message when clicking date in chat (#21926)
This PR adds a new parameter to fetch chat messages: `target_date`.

It can be used to fetch messages by a specific date string. Note that it does not need to be the `created_at` date of an existing message, it can be any date. Similar to `target_message_id`, it retrieves an array of past and future messages following the query limits.
2023-06-20 15:58:38 +02:00
Martin Brennan fc199d42fa
FIX: Add aria-label attribute to cooked hashtags (#22182)
This commit adds an aria-label attribute to cooked hashtags using
the post/chat message decorateCooked functionality. I have just used
the inner content of the hashtag (the tag/category/channel name) for
the label -- we can reexamine at some point if we want something
different like "Link to dev category" or something, but from what I
can tell things like Twitter don't even have aria-labels for hashtags
so the text would be read out directly.

This commit also refactors any ruby specs checking the HTML of hashtags
to use rspec-html-matchers which is far clearer than having to maintain
the HTML structure in a HEREDOC for comparison, and gives better spec
failures.

c.f. https://meta.discourse.org/t/hashtags-are-getting-a-makeover/248866/23?u=martin
2023-06-20 15:47:17 +10:00
Natalie Tay 9afb9e6142
DEV: Update chat cooked quote spec (#22202)
A side effect of #21522 that went unnoticed.
2023-06-20 10:30:33 +08:00
Sam 9e241e82e9
DEV: use HTML5 version of loofah (#21522)
https://meta.discourse.org/t/markdown-preview-and-result-differ/263878

The result of this markdown had different results in the composer preview and the post. This is solved by updating Loofah to the latest version and using html5 fragments like our user had reported. While the change was only needed in cooked_post_processor.rb for this fix, other areas also had to be updated due to various side effects.
2023-06-20 09:49:22 +08:00
Joffrey JAFFEUX cbb9396353
REFACTOR: <ChatMessage> component (#22172)
- Moves `<ChatMessageInfo />` to `<Chat::Message::Info />`
- Moves `<ChatMessageAvatar />` to `<Chat::Message::Avatar />`
- Moves `<ChatMessageLeftGutter />` to `<Chat::Message::LeftGutter />`, adds tests
- Creates `<Chat::Message::Error />`
- Creates `<Chat::Message::MentionWarning />`, adds tests and a styleguide
- Creates a model for ChatMessageMentionWarning, adds fabricator for it
- Keeps the enter/leave viewport logic inside the `<ChatMessage />` component instead of bubbling it to the channel and thread components
- Adds a scale animation when clicking a reaction
- Creates `chat/later-fn` modifier which accepts a function and a delay. It allows to call a function Xms after a component has been inserted, it's useful for animations.
- Moves css code out of chat-message into relevant files
- Deletes unused code

<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2023-06-19 09:50:54 +02:00
Joffrey JAFFEUX 7e1d015657
DEV: more reliable thread level spec (#22173)
Rely on frontend state instead of checking backend state.
2023-06-17 14:28:22 +02:00
David Taylor 4b9d50c98a DEV: Update poll components and controllers to native class syntax
Conversion performed using the ember-native-class-codemod
2023-06-16 18:16:31 +01:00
David Taylor aebe6625d2 DEV: Modernize poll JS directory structure and colocate components 2023-06-16 18:16:31 +01:00
David Taylor 6e143c6157
DEV: Namespace chat_header_indicator UserOption enum (#22152)
Previously this was defining methods like `UserOption#never?`, `UserOption#all_new?`, `UserOption#dm_and_mentions?`. Now they will be prefixed like `UserOption#chat_header_indicator_never?`
2023-06-16 13:14:53 +01:00
Joffrey JAFFEUX 7db6d27292
FIX: correctly sets and uses has-reply class (#22153)
The layout was broken for messages replying to another message in non threaded channels.

This commit also refactors the chat-message-test to use fabricators.
2023-06-16 14:04:11 +02:00
David Taylor 54cae1299e
DEV: Do not attempt to overwrite UserOption enums during autoloading (#22150)
Unfortunately, Discourse's `UserOption` model is not currently autoloaded. That means that modifying it via a `reloadable_patch` will try to apply the changes repeatedly. Normally this doesn't matter since the changes are idempotent. However, introducing ActiveRecord enums is not idempotent - they raise an error if the same enum already exists on the model. This commit adds a check to avoid hitting this 'duplicate definition' error.

Reproduced

```
rails runner 'Rails.application.reloader.reload!'
```
2023-06-16 12:29:32 +01:00
Joffrey JAFFEUX ab286cc6e1
FIX: css class was incorrect (#22149)
This was preventing to have the correct active background on the chat message while hovering the action's menu.
2023-06-16 12:33:13 +02:00