Commit Graph

2220 Commits

Author SHA1 Message Date
David Battersby 967010e545
FEATURE: Add an emoji deny list site setting (#20929)
This feature will allow sites to define which emoji are not allowed. Emoji in this list should be excluded from the set we show in the core emoji picker used in the composer for posts when emoji are enabled. And they should not be allowed to be chosen to be added to messages or as reactions in chat.

This feature prevents denied emoji from appearing in the following scenarios:
- topic title and page title
- private messages (topic title and body)
- inserting emojis into a chat
- reacting to chat messages
- using the emoji picker (composer, user status etc)
- using search within emoji picker

It also takes into account the various ways that emojis can be accessed, such as:
- emoji autocomplete suggestions
- emoji favourites (auto populates when adding to emoji deny list for example)
- emoji inline translations
- emoji skintones (ie. for certain hand gestures)
2023-04-13 15:38:54 +08:00
Alan Guo Xiang Tan d86691a767
DEV: Skip flaky test on actions (#21072)
https://github.com/discourse/discourse/actions/runs/4675927190/jobs/8281605117
2023-04-12 16:51:00 +08:00
Alan Guo Xiang Tan 2eb60c9713
DEV: Switch sidebar section link identifier to data attribute (#21051)
Data attribute is less restrictive than relying on the class attribute
2023-04-12 15:52:10 +08:00
Martin Brennan 584a17c948
FEATURE: Initial chat thread indicator and disabling echo mode in channels (#21047)
This commit introduces a new thread indicator for channels with `threading_enabled`
set to true and the `enable_exp` site setting set to true. In addition, in the main channel
stream we now hide all messages that are linked to threads except for the original message,
disabling the concept of an "echo mode" for now, we may revisit this in future. We also
remove the jigsaw puzzle "Open Thread" button for message actions, since the thread
indicator can just be used instead.

This also stops the `Chat::Publisher` from sending any messages related to chat
messages that are linked to a thread, unless that chat message is the OM of the
thread. A subsequent PR will link up all MessageBus events within the thread panel,
and for the message indicators.

Another subsequent PR will add the excerpt of the latest message in each thread,
as well as the avatars of the users messaging in the thread.

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2023-04-12 11:09:06 +10:00
Discourse Translator Bot 9a562f54d7
Update translations (#21055) 2023-04-11 15:45:03 +02:00
Joffrey JAFFEUX f55266e1ca
UX: chat mobile tweaks (#21041)
- rounded active style for messages
- better active state on chat message actions rows
- ensures long press on a message is not selecting text
- slightly improved messages actions animation and background fading
- ensures chat emoji picker is not cutoff on right side
- removes old legacy code related to hovered message
2023-04-11 09:03:12 +02:00
Martin Brennan e34fb7e0b2
DEV: Chat thread reply counter cache (#21050)
Similar to 22a55ef0ce,
this commit adds a replies_count to the Chat::Thread
table, which is updated every 15 minutes via PeriodicalUpdates.
This is done so the new thread indicator for the UI can
show the count without intense serializer queries, but
in future we likely want this to update more frequently.
2023-04-11 15:40:25 +10:00
Martin Brennan 7ae716fa69
FIX: Multiple channels marked active in sidebar (#21045)
Followup to c1dc6a2db4,
this commit just missed removing one of the @computed
decorators which was causing multiple active channels
to show in the sidebar. Fix the issue and introduce a
system spec to catch this.
2023-04-11 12:31:17 +10:00
Joffrey JAFFEUX c1dc6a2db4
FIX: ensures activeMessage is reset with channel (#21031) 2023-04-10 08:10:01 +02:00
Joffrey JAFFEUX c7b49a14c7
Chat/drawer ux tweaks (#21032)
- clicking empty area on the header will toggle collapse/expand it
- applies a background on hover of the channel title
- active state for small buttons
- the back button now has the correct icon color when hovered
- adds missing focus state for heade buttons icons
2023-04-10 07:43:11 +02:00
Jan Cernik 768851920e
DEV: Add `overflow-x: hidden` to chat message containers (#21030) 2023-04-08 13:37:13 -03:00
Jan Cernik a6cba32e57
FIX: Resize chat collapser when using small width drawer (#21017) 2023-04-08 10:43:17 -03:00
Joffrey JAFFEUX 3176d4cb5a
FIX: ensures message actions are bounded (#21027) 2023-04-07 20:54:41 +02:00
Joffrey JAFFEUX 720cf24659
FIX: shows a message as hovered when hovering actions (#21026)
When hovering the chat message actions we are technically not hovering the message anymore, which was removing the background and is slightly unexpected. This commit ensures we keep this background until closing the message actions.
2023-04-07 20:29:33 +02:00
Joffrey JAFFEUX 6d99e6408f
FIX: correctly show user info (#21023)
This PR primarily fixes this case:

- USER A message
- USER B message
- USER B reply to USER A message <-- not showing user info when it should

Moreover, this commit also improves the spec to correctly test more cases.
2023-04-07 20:08:31 +02:00
Joffrey JAFFEUX 9117ea0e3f
FIX: scroll when clicking first emoji of section (#21020)
This bug was also happening when tabbing through sections
2023-04-07 14:11:25 +02:00
Joffrey JAFFEUX 79cacba948
FIX: cancel editing should clear the composer (#21011) 2023-04-07 09:55:55 +02:00
Joffrey JAFFEUX fef279acd5
FIX: do not display the message content when it errors (#21008) 2023-04-06 19:32:21 +02:00
Daniel Waterworth 0ff86feb96
DEV: Rely on helpers for ajax error handling to reduce repetition (#20988) 2023-04-06 11:25:24 -05:00
Joffrey JAFFEUX 5c2c1bf9a7
FIX: correct backdrop on mobile for the emoji picker (#21005) 2023-04-06 15:51:40 +02:00
Martin Brennan ea548292bc
DEV: Refactoring chat message actions for ChatMessage component usage in thread panel (#20756)
This commit is a major overhaul of how chat message actions work, to make it so they are reusable between the main chat channel and the chat thread panel, as well as many improvements and fixes for the thread panel.

There are now several new classes and concepts:

* ChatMessageInteractor -  This is initialized from the ChatMessage, ChatMessageActionsDesktop, and ChatMessageActionsMobile components. This handles permissions about what actions can be done for each
message based on the context (thread or channel), handles the actions themselves (e.g. copyLink, delete, edit),
and interacts with the pane of the current context to modify the UI
* ChatChannelThreadPane and ChatChannelPane services - This represents the UI context which contains the
messages, and are mostly used for state management for things like message selection.
* ChatChannelThreadComposer and ChatChannelComposer - This handles interaction between the pane, the
message actions, and the composer, dealing with reply and edit message state.
* Scrolling logic for the messages has now been moved to a helper so it can be shared between the main channel pane and the thread pane
* Various improvements with the emoji picker on both mobile and desktop. The DOM node of each component is now located outside of the message which prevents a large range of issues.

The thread panel now also works in the chat drawer, and the thread messages have less
actions than the main panel, since some do not make sense there (e.g. moving messages to
a different channel). The thread panel title, excerpt, and message sender have also been removed
for now to save space.

This gives us a solid base to keep expanding on and fixing up threads. Subsequent PRs will
make the thread MessageBus subscriptions work and disable echo mode
for the initial release of threads.

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2023-04-06 15:19:52 +02:00
Joffrey JAFFEUX 838fb37019
FIX: accounts for `hide_profile_and_presence` core user option (#20991)
Chat will now correctly use this core setting and will not show the presence of the user in this case.
2023-04-06 09:29:54 +10:00
Discourse Translator Bot 171e8b679d
Update translations (#20861) 2023-04-05 09:12:48 +02:00
Martin Brennan 6ad9e4ad06
FEATURE: Add CSS class generation for category colors and hashtags (#20951)
This commit adds a system to generate CSS variables and classes for categories
and hashtags, which will be used in an effort to remove baked icons for hashtags
and add color to those icons.

This is in two parts. First I added an initializer generate a category color CSS
variable style tag in the head tag that looks like this:

```css
:root {
--category-1-color: #0088CC;
--category-2-color: #808281;
--category-3-color: #E45735;
--category-4-color: #A461EF;
--category-5-color: #ee56c9;
--category-6-color: #da28c2;
--category-7-color: #ab8b0a;
--category-8-color: #45da37;
...
}
```

The number is the category ID. This only generates CSS variables for categories
the user can access based on `site.categories`. If you need the parent color variable
you can just use the `category.parentCategory.id` to get it.

Then, I added an initializer to generate a hashtag CSS style tag using these variables.
Only the category and channel hashtags need this, the category one generates the
background-gradient needed for the swatch, and the channel just generates a color
for the icon. This is done in an extendable way using the new `api.registerHashtagType`
JS plugin API:

```css
hashtag-color--category-1 {
  background: linear-gradient(90deg, var(--category-1-color) 50%, var(--category-1-color) 50%);
}
hashtag-color--category-2 {
  background: linear-gradient(90deg, var(--category-2-color) 50%, var(--category-2-color) 50%);
}
hashtag-color--category-5 {
  background: linear-gradient(90deg, var(--category-5-color) 50%, var(--category-4-color) 50%);
}
...
.hashtag-color--channel-4 {
  color: var(--category-12-color);
}
.hashtag-color--channel-92 {
  color: var(--category-24-color);
}
```

Note if a category has a parent, its color is used in the gradient correctly. The numbers
here are again IDs (e.g. channel ID, category ID) and the channel’s chatable ID is used
to find the category color variable.
2023-04-05 13:02:35 +10:00
Bianca Nenciu 6da2fbbf76
FIX: Use correct translation key (#20958)
The translation key is built using the name of the reviewable as it was
defined in Ruby. The chat plugin uses the `Chat` namespace and defines
`Chat::ReviewableMessage`. This was then transformed to
`chat::reviewable_message`, but it should be `chat_reviewable_message`
to resemble the other translation keys.
2023-04-04 16:28:04 +03:00
chapoi 6e2fd7a451
UX: Chat channel title overflow ellipsis fixes (#20956)
* UX: add correct class

* UX: prioritise name over user messages when truncating

* UX: add missing overflows to enable ellipsis
2023-04-04 12:44:36 +02:00
Jan Cernik b4096f4636
FIX: Add lazy-videos support for Vimeo unlisted videos (#20916) 2023-04-03 22:49:32 -03:00
Martin Brennan 894586afa9
FIX: Trashing message should reset last read (#20912)
When a chat message is trashed and the message is used
for someone's UserChatChannelMembership#last_read_message_id,
the user would end up with some read state issues until
someone posted a new message in the channel, since we didn't
clear it like we did on bulk message delete.

This commit fixes the issue, and also takes the opportunity
to start a MessagesController in the API namespace, and move
the trash message functionality into the new service format.
2023-04-04 09:30:38 +10:00
Martin Brennan c00d17535f
DEV: Drop chat_uploads table and model and remove old references (#20926)
Followup to 0924f874bd,
we migrated Chat::Upload records to UploadReference records
there and have not been making new Chat::Upload records
for some time, we can now delete the model and table.
2023-04-04 09:13:39 +10:00
Jarek Radosz 29e2e3ff3b
DEV: Fix random typos (#20937) 2023-04-03 19:27:32 +02:00
Joffrey JAFFEUX 1219f41c68
UX: multiple minor improvements (#20917)
- Raises the scroll distance to 250px instead of 100px to show the arrow down button
- Always have a margin on drawer when showing channel list, removes this margin when the scrollbar is apparent
- Makes all scrollbar used in chat look the same through the chat-scrollbar mixin
- Ensures hover state is not persistent on channel row in mobile
- Makes the channel row full width on mobile
2023-04-03 10:46:38 +02:00
Jan Cernik af98df8cb9
FIX: Vertically center youtube thumbnails in lazy-videos (#20914) 2023-03-31 09:41:58 -03:00
Martin Brennan f7997ae882
DEV: Add debug for ChatablesControllerSpec (#20909)
We keep getting this failure on the spec but I
cannot reproduce locally, add this extra log line
to see if it helps:

```
>  Chat::Api::ChatablesController#index with chat permissions does not return DM channels for users who are not in the chat allowed group
>  Failure/Error: example.run
>
>    expected: 200
>         got: 500
>
>    (compared using ==)
>  # ./plugins/chat/spec/requests/chat/api/chatables_controller_spec.rb:158:in `block (4 levels) in <main>'
>  # ./spec/rails_helper.rb:358:in `block (2 levels) in <top (required)>'
>  # ./vendor/bundle/ruby/3.2.0/gems/webmock-3.18.1/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'
>  # ------------------
>  # --- Caused by: ---
>  #
>  #   expected: 200
>  #        got: 500
>  #
>  #   (compared using ==)
>  #   ./plugins/chat/spec/requests/chat/api/chatables_controller_spec.rb:158:in `block (4 levels) in <main>'

```
2023-03-31 11:50:12 +10:00
Joffrey JAFFEUX 6ba24b3599
UX: prevents long press on reaction to open actions (#20899)
This is super hard to write a test as a combination of: long press, mobile and popup.
2023-03-30 20:01:38 +02:00
Martin Brennan f8ff97b2ec
DEV: Add specs to ChannelSerializer and StructuredChannelSerializer (#20872)
This adds specs to the mentioned serializers to catch regressions
with MessageBus last_ids and to ensure the correct ones are being
returned and passed down to the ChannelSerializer.

Followup to d8ad5c3
2023-03-30 12:16:32 +10:00
Jan Cernik afe3e36363
DEV: Remove lazy-yt and replace with lazy-videos (#20722)
- Refactors the old plugin to remove jquery usage
- Adds support for Vimeo videos (default on) and Tiktok (experimental and default off)
2023-03-29 11:54:25 -04:00
Joffrey JAFFEUX 69de5b161f
FIX: ensures removing a reaction doesn’t remove others (#20869) 2023-03-29 08:39:52 +02:00
Martin Brennan 70c0955722
DEV: Uncomment chat upload system specs (#20859)
These were commented in  daaa41ae07,
doesn't seem to have made an observable difference, uncommenting
these now to see if chat system specs still pass.
2023-03-28 10:55:01 -04:00
Martin Brennan d8ad5c38b9
FIX: channel_message_bus_last_id was incorrect (#20858)
Followup to 3ea8df4b06,

I forgot to wrap the call to Chat::Publisher.root_message_bus_channel(object.chat_channel.id)
in MessageBus.last_id, so the channel_message_bus_last_id key was
ending up as e.g. "/chat/58" instead of the last ID value.
2023-03-28 16:01:27 +10:00
Martin Brennan 3ea8df4b06
DEV: Fix excessive MessageBus#last_id calls in chat (#20855)
We noticed via profiling that chat was doing N redis calls
per channel. Part of this was from the kick_message_bus_last_id
from 520d4f504b being incorrectly
passed down for DM channels rather that public channels, and the
other part was from the root MessageBus channel last_id
being fetched in ChannelSerializer for every single channel.

This commit fixes both issues, for me going from 134 redis calls
on page load to 20 locally.

Also deletes an old file missed in 12a18d4d55
2023-03-28 14:45:45 +10:00
Martin Brennan c912c58d6c
FIX: Make chat tracking payload backwards compatible (#20852)
Followup cab4b2cfba,
this was causing client JS errors because the old version
of the client was expecting the old keys, but the new
ruby version of the app was sending different keys via
the MessageBus payload. We can remove this in a couple
of weeks.
2023-03-28 12:56:32 +10:00
Martin Brennan cab4b2cfba
DEV: Introduce bulk channel tracking publisher (#20838)
This commit introduces a Chat::Publisher and MessageBus endpoint
that allows for updating a user's channel tracking state in bulk for
multiple channels, rather than having to do it for one channel
at a time.

This also required an improvement to ChannelUnreadsQuery -- now
multiple channel IDs can be passed to this to get the unread counts
and mention counts for those channels for a user, also increasing
efficiency rather than having to do a query for every individual
channel.

Followup to #20802
2023-03-28 09:36:28 +10:00
Penar Musaraj daaa41ae07
WIP: Skip system specs with upload fabricators (#20821)
A shot in the dark to see if these are the culprits for the many random
spec failures in CI.
2023-03-27 13:11:17 -04:00
Jarek Radosz cbabc01e0e
DEV: Make `capabilities` into a service (#18678) 2023-03-27 19:06:36 +02:00
Joffrey JAFFEUX 05174a6abd
DEV: correctly tests text is rendered in replies (#20845) 2023-03-27 15:42:30 +02:00
Jarek Radosz 65b1381575
DEV: Fix a constant redefinition warning (#20842) 2023-03-27 13:34:25 +02:00
Martin Brennan 55ef4d9a98
FIX: Make sure marking channels read propagates to all tabs (#20802)
Instead of just marking the state read in JS for each channel
after the AJAX call, we can instead just rely on the MessageBus
user-tracking-state chat channel, and publish the state to all
the channels affected in MarkAllUserChannelsRead. This will make
it so the blue dots for the channels are cleared across all tabs.
2023-03-24 10:12:35 +01:00
Joffrey JAFFEUX 67913e59e0
FIX: relies only on message bus to set tracking state (#20785)
This manual set was happening only after the request so was not much faster than just waiting on message bus update. It's not by itself changing any behavior or fixing any bug but it makes reasoning about the whole state easier as it happens in only one central place.
2023-03-23 11:11:13 +01:00
Alan Guo Xiang Tan 2d46824a87
DEV: Switch to data attributes to represent sidebar section name (#20771)
Data attributes are less restrictive than the class attribute.
2023-03-23 13:09:45 +08:00
Martin Brennan 5d4c5d959a
FIX: Make sure "last visit" is not shown after marking all messages read (#20782)
Followup to a0381157e9, we just
need to make sure we set currentUserMembership.last_read_message_id
to the last_read_message_id from the updated memberships after marking
all channels read, otherwise we do not scroll to the bottom and still
show the "last visit" separators in channels that have been
marked read.
2023-03-23 13:18:55 +10:00
Discourse Translator Bot 6406d8e4cb
Update translations (#20760) 2023-03-22 12:13:36 +01:00
Martin Brennan a0381157e9
FEATURE: Mark all chat channels read with a shortcut (#20629)
This commit adds a keyboard shortcut (Shift+ESC) for chat which marks all
of the chat channels that the user is currently a following member of as read,
updating their `last_read_message_id`. This is done via a new service.

It also includes some refactors and controller changes:

* The old mark message read route from `ChatController` is now supplanted
  by the `Chat::Api::ReadsController#update` route.
* The new controller can handle either marking a single or all messages read,
  and uses the correct service based on the route and params.
* The `UpdateUserLastRead` service is now used (it wasn't before), and has been slightly
  updated to just use the guardian user ID.
2023-03-22 13:24:07 +10:00
Martin Brennan 786f7503b4
DEV: Skip channel-wide mention chat specs (#20770)
These were added in 7dd317b875
but are now consistently failing with described_class.chat_summary(user, {})
returning nil. Skipping for now because they are holding up other
things.

To reproduce failure run:

RSPEC_SEED=46586 bundle exec rake plugin:spec
2023-03-22 12:44:01 +10:00
Martin Brennan 520d4f504b
FEATURE: Auto-remove users without permission from channel (#20344)
There are many situations that may cause users to lose permission to
send messages in a chat channel. Until now we have relied on security
checks in `Chat::ChatChannelFetcher` to remove channels which the
user may have a `UserChatChannelMembership` record for but which
they do not have access to.

This commit takes a more proactive approach. Now any of these following
`DiscourseEvent` triggers may cause `UserChatChannelMembership`
records to be deleted:

* `category_updated` - Permissions of the category changed
   (i.e. CategoryGroup records changed)
* `user_removed_from_group` - Means the user may not be able to access the
   channel based on `GroupUser` or also `chat_allowed_groups`
* `site_setting_changed` - The `chat_allowed_groups` was updated, some
   users may no longer be in groups that can access chat.
* `group_destroyed` - Means the user may not be able to access the
   channel based on `GroupUser` or also `chat_allowed_groups`

All of these are handled in a distinct service run in a background
job. Users removed are logged via `StaffActionLog` and then we
publish messages on a per-channel basis to users who had their
memberships deleted.

When the user has a channel they are kicked from open, we show
a dialog saying "You no longer have access to this channel".

When they click OK we redirect them either:

* To their first other public channel, if they have any followed
* The chat browse page if they don't

This is to save on tons of requests from kicked out users getting messages
from other channels.

When the user does not have the kicked channel open, we can just
silently yoink it out of their sidebar and turn off subscriptions.
2023-03-22 10:19:59 +10:00
Joffrey JAFFEUX b5c4e1b813
FIX: do not refresh metadata of not followed channel (#20766) 2023-03-21 20:13:44 +01:00
Andrei Prigorshnev 0562f952ed
DEV: no need to pass down `skip_notifications` for expanding mentions (#20683)
This refactoring simplifies ChatNotifier a bit. I wanted to drop 
that argument for expand_direct_mentions too, but that needs 
a bit deeper refactoring, so it's better to do it separately.

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2023-03-21 19:44:24 +04:00
Kris 147941a5d7
UX: update chat icon to d-chat (#20744) 2023-03-21 10:40:42 -04:00
Joffrey JAFFEUX 7ccc7b75b2
FIX: ensures user with multiple tabs see own reactions (#20759)
Prior to this fix, we wouldn't display reactions done on different tabs. So, if user A was reacting on tab 1, tab 2 wouldn't display this reaction.

Since few weeks ago we now have the guarantee to have uniq reactions on a message which should prevent any duplicate.

This commit also removes various skipped tests related to reactions and makes `sign_in` explicit at the beginning of each test.

<!-- 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-03-21 15:25:35 +01:00
Joffrey JAFFEUX 92797109ba
DEV: uses container resize event instead of mutation (#20757)
This commit takes advantage of the `ResizeObserver` to know when dates should be re-computed, it works like this:

```
scrollable-div
--  child-enclosing-div with resize observer
---- message 1
---- message 2
---- message x
```

It also switches to bottom/height for date separators sizing, instead of bottom/top, it prevents a bug where setting the top of the first item (at the top) would cause scrollbar to move to top.

<!-- 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-03-21 11:30:32 +01:00
Martin Brennan 0a06974a8a
DEV: Rough chat message loading and posting in thread (#20579)
This commit does a couple of things:

* Adds the ability to load messages in the chat thread panel when it is open. This just loads the most recent N messages, same as a channel, and does nothing more, no scrolling or anything like that.
* Displays the messages in an extremely simple unordered list with no additional features.
* Allows posting new messages to the thread, and echoes them into the main channel, but does not respond to any sort of MessageBus events.

I've moved messages/clearMessages/addMessages/findMessage code out of the `ChatChannel` model
and into a new `ChatMessagesManager` class, which is instantiated in both the `ChatChannel` model
and the `ChatThread` model. This allows both to manage messages in the same way via the
`TrackedArray` pattern.

This is all hidden behind experimental flags, there is no way to make this not completely broken
in a single commit. Much more work and refactoring needs to be done first.

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2023-03-21 15:29:10 +10:00
Joffrey JAFFEUX 53cadac4b8
UX: disables composer auto focus on drawer (#20751)
This behavior was interfering with topics shortcuts.
2023-03-20 22:24:12 +01:00
Joffrey JAFFEUX 25d06faa8b
FIX: correctly checks for chat enabled in incoming webhooks controller (#20730)
This commit also moves the spec into the correct folder
2023-03-20 09:42:36 +01:00
Jarek Radosz 38fdd842f5
UX: Fix chat separator alignment (#20669)
Also: work around 1px svg shift in scroll-to-bottom button
2023-03-18 18:03:54 +01:00
Joffrey JAFFEUX aeab38aff1
UX: disable arrow up to edit if last message is not editable (#20729) 2023-03-17 23:08:10 +01:00
Joffrey JAFFEUX aa8eff5e16
FIX: ensures updateLastRead is called when receiving a message (#20728)
This behavior is hard to test as it's mostly fixing a race condition: User A sends a message at the same time than User B, which as a result doesn't cause a scroll for the second message and we don't update last read unless we do a small up and down scroll.

`updateLastRead` is debounced so it has no direct consequences to call it slightly more often than what should ideally be needed.
2023-03-17 22:46:59 +01:00
Joffrey JAFFEUX cfee0cfee9
FIX: ensures lightbox is working after collapse/expand (#20724)
Prior to this fix, the upload was removed from DOM when collapsed and not decorated again on expand, which was causing lightbox to not get reapplied. The fix is reverting to previous state where content was not removed from DOM.
2023-03-17 18:26:32 +01:00
Joffrey JAFFEUX c5e5b6d5ab
DEV: fixes a flakey spec (#20721) 2023-03-17 18:01:19 +01:00
Joffrey JAFFEUX 184ce647ea
FIX: correctly infer polymorphic class from bookmarkable type (#20719)
Prior to this change `registered_bookmarkable` would return `nil` as  `type` in `Bookmark.registered_bookmarkable_from_type(type)` would be `ChatMessage` and we registered a `Chat::Message` class.

This commit will now properly rely on each model `polymorphic_class_for(name)` to help us infer the proper type from a a `bookmarkable_type`.

Tests have also been added to ensure that creating/destroying chat message bookmarks is working correctly.

---

Longer explanation

Currently when you save a bookmark in the database, it's associated to another object through a polymorphic relationship, which will is represented by two columns: `bookmarkable_id` and `bookmarkable_type`. The `bookmarkable_id` contains the id of the relationship (a post ID for example) and the `bookmarkable_type` contains the type of the object as a string by default, (`"Post"` for example).

Chat plugin just started namespacing objects, as a result a model named `ChatMessage` is now named `Chat::Message`, to avoid complex and risky migrations we rely on methods provided by rails to alter the `bookmarkable_type` when we save it: we want to still save it as `"ChatMessage"` and not `"Chat::Message"`. And, to retrieve the correct model when we load the bookmark from the database: we want `"ChatMessage"` to load the `Chat::Message` model and not the `ChatMessage`model which doesn't exist anymore.

On top of this the bookmark codepath is allowing plugins to register types and will check against these types, so we alter this code path to be able to do a similar ChatMessage <-> Chat::Message dance and allow to check the type is valid. In the specific case of this commit, we were retrieving a `"ChatMessage"` bookmarkable_type from the DB and looking for it in the registered bookmarkable types which contain `Chat::Message` and not `ChatMessage`.
2023-03-17 17:20:24 +01:00
Joffrey JAFFEUX 12a18d4d55
DEV: properly namespace chat (#20690)
This commit main goal was to comply with Zeitwerk and properly rely on autoloading. To achieve this, most resources have been namespaced under the `Chat` module.

- Given all models are now namespaced with `Chat::` and would change the stored types in DB when using polymorphism or STI (single table inheritance), this commit uses various Rails methods to ensure proper class is loaded and the stored name in DB is unchanged, eg: `Chat::Message` model will be stored as `"ChatMessage"`, and `"ChatMessage"` will correctly load `Chat::Message` model.
- Jobs are now using constants only, eg: `Jobs::Chat::Foo` and should only be enqueued this way

Notes:
- This commit also used this opportunity to limit the number of registered css files in plugin.rb
- `discourse_dev` support has been removed within this commit and will be reintroduced later

<!-- 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-03-17 14:24:38 +01:00
Blake Erickson 5103d249aa DEV: Skip chat channel test
The screenshot looks good, but the test appears to be bad. Skipping this
test for now, will follow-up later.
2023-03-16 15:27:09 -06:00
Blake Erickson 6dcb099547 FIX: Escaped mentions in chat excerpts
Mentions are now displayed as using the non-cooked message which fixes
the problem. This is not ideal. I think we might want to rework how
these excerpts are created and rendered in the near future.

Co-authored-by: Jan Cernik <jancernik12@gmail.com>
2023-03-16 15:27:09 -06:00
Blake Erickson a373bf2a01 SECURITY: XSS on chat excerpts
Non-markdown tags weren't being escaped in chat excerpts. This could be
triggered by editing a chat message containing a tag (self XSS), or by
replying to a chat message with a tag (XSS).

Co-authored-by: Jan Cernik <jancernik12@gmail.com>
2023-03-16 15:27:09 -06:00
Andrei Prigorshnev 7dd317b875
DEV: add test cases for email notifications about channel-wide mentions (#20691)
A follow-up to e6c04e2d.
2023-03-16 21:43:56 +04:00
Andrei Prigorshnev 94fd884297
DEV: remove unused string (#20662)
The button was removed in fca6805a
2023-03-16 00:15:07 +04:00
Andrei Prigorshnev e6c04e2dc2
FIX: do not send emails when channel-wide mentions are disabled in a channel (#20677)
This regressed with the commit fa543cd. Starting from that commit, we create mention records even if a user shouldn't be notified. So when sending emails, we should be making sure if a notification was actually created for a mention. This is essentially the whole fix that we need here. Tests will be provided in a following PR.
2023-03-14 21:45:05 +04:00
Discourse Translator Bot 4cf065c480
Update translations (#20671) 2023-03-14 15:04:54 +01:00
Joffrey JAFFEUX 727100d1e2
DEV: adds a `addChatDrawerStateCallback` API (#20640)
Usage:

```javascript
api.addChatDrawerStateCallback(({ isDrawerActive, isDrawerExpanded }) => {
  // do something
});
```

Note this commit also uses this new API to add a css class (chat-drawer-active) on the body when the drawer is active.
2023-03-10 18:49:59 +01:00
Joffrey JAFFEUX ada89d6124
FIX: ensures edited message is correctly re-decorated (#20637) 2023-03-10 17:06:13 +01:00
Joffrey JAFFEUX 60ce3d24fa
FIX: more consistent scroll to bottom (#20634)
This fix uses direct `scrollTop` manipulation instead of `scrollIntoView` when we are certain we actually want the bottom of the screen. This avoids a range of issues especially in safari but also chrome where the scroll position was not correct at the end of `scrollIntoView`, especially due to images.
2023-03-10 16:25:21 +01:00
Andrei Prigorshnev 7df40fc905
DEV: do not fabricate a notification when fabricating a chat_mention (#20636)
This is just a little clean-up in tests. In the past, when creating a `chat_mention` 
record, we always created a related notification. Starting from fa543cda 
notifications and chat_mentions are fully decoupled from each other. So if we're 
testing just chat mentions there is no need to fabricate notifications for them.
2023-03-10 18:32:33 +04:00
Martin Brennan 168de52538
DEV: Change sidebar header dropdown to use wait_for_animation (#20627)
* DEV: Change sidebar header dropdown to use wait_for_animation

Introduced in 54351e1b8a, this
helper should remove the need to have to add the .animated
CSS class in JS for the sidebar.

* DEV: Revert spec change
2023-03-10 14:54:57 +10:00
Andrei Prigorshnev e292c45924
DEV: better split create_notification! and send_notifications logic (#20562)
`create_notification!` - creates a notification in the database, `send_notifications` sends desktop and mobile notifications. This PR moves some code to decouple these two tasks more explicitly. It only moves code without changing any behavior, and the job is covered with tests (see chat_notify_mentioned_spec).
2023-03-09 22:17:18 +04:00
Joffrey JAFFEUX 73be7b3dd8
FIX: improves unread state precision (#20615)
- Will consider a message read only one the bottom of the message has been read
- Will allow to mark a message bigger than the view port as read
- Code should be more performant as the scroll is doing less (albeit more often)
- Gives us a very precise scroll state. Problem with throttling scroll is that you could end up never getting the even where scrollTop is at 0, opening a whole range of edge cases to handle
2023-03-09 19:06:33 +01:00
Jarek Radosz 3c4bfb6a9f
UX: Tweak last-visit/date separators (#20601)
1. Restore the left margin on both (which reflects the right margin of the scroll bar space)
2. Fix the center alignment of scroll-to-bottom icon
3. Fix the spacing of the `-` character between a date label and "last visit" label
4. Fix the incorrect display the border on date label when at the bottom of viewport
2023-03-09 13:44:02 +01:00
Martin Brennan ba1b95c9f4
FIX: Uploading multiple files to chat could cause canellations (#20605)
When we introduced `existingUploads` as an arg to the
ChatComposerUploads component, we also introduced a bug where
if multiple uploads were being done at once, and the draft
was saved, then because of didReceiveAttrs we would cancel
the currently uploading files because the draft uploads became
the existingUploads.

To work around this, since we do want to keep this on didReceiveAttrs
for cases when the user opens a draft or edits another message,
the easiest thing to do is to just not save uploads into the chat
draft if there are still uploads in progress. That way only when
all uploads are complete do we make them a part of the draft.

There is a small risk that the user could do something to lose
their uploads in the draft, but it's a better gamble to have
that happen rather than in progress uploads to be cancelled
while the user is waiting for them to be done because of the
draft.

Also changes the uploads system spec back to the old way of
attaching multiple files since that is why it was failing.
2023-03-09 09:17:54 +01:00
Martin Brennan 931eedeb66
Revert "FIX: more precise unread message detection (#20588)" (#20604)
This reverts commit d78fed7dc6.

Causing some issues with clearing unreads.
2023-03-09 11:03:33 +10:00
Joffrey JAFFEUX f76ea32246
FIX: broken sticky date on firefox (#20594) 2023-03-08 22:23:24 +01:00
Jarek Radosz c25d79168b
UX: Fix chat-reply overflow (#20592) 2023-03-08 21:12:49 +01:00
Joffrey JAFFEUX d78fed7dc6
FIX: more precise unread message detection (#20588) 2023-03-08 17:28:54 +01:00
Joffrey JAFFEUX 4f2dfd3857
FIX: correctly syncs current user message in multiple sessions (#20584) 2023-03-08 17:28:39 +01:00
Martin Brennan 54351e1b8a
DEV: Introduces a wait_for_animation system spec helper (#20573)
This is used when calling click_message_action_mobile to wait
for the message actions menu to finish animating up before
attempting to click on it using capybara. Without this, in
the time between capybara getting the x,y position of a menu
item to click on and the click being fired, the animating menu
can move that item out of the way.

With the new helper, we constantly compare x,y client rect positions
for the animating element and wait for them to stabilise. Once they
do, it means the animation is done, and it is safe to click on
anything within the element.

Re-enables mobile system specs for chat that were ignored because
of this.
2023-03-08 16:49:20 +01:00
Joffrey JAFFEUX 7f486cbc9b
FIX: do not show infinite loading state on draft with new users (#20582) 2023-03-08 15:21:20 +01:00
Martin Brennan b62d44b40a
DEV: Fix another chat bookmark spec (#20578)
Followup to a252022117
2023-03-08 14:55:14 +10:00
Martin Brennan a252022117
DEV: Fix broken plugin specs because of bookmarkable changes (#20574) 2023-03-08 10:39:51 +08:00
Martin Brennan 360d0dde65
DEV: Change Bookmarkable registration to DiscoursePluginRegistry (#20556)
Similar spirit to e195e6f614,
this moves the Bookmarkable registration to DiscoursePluginRegistry
so plugins which are not enabled do not register additional
bookmarkable classes.
2023-03-08 10:39:12 +10:00
Joffrey JAFFEUX 2781264711
PERF: various perf improvements of chat-live-pane (#20563) 2023-03-07 18:55:05 +01:00
Andrei Prigorshnev fa543cda06
DEV: Always create chat mention records (#20470)
Before this commit, we created a chat mention record only in case we wanted to send a notification about that mention to the user. Notifications were the only use case for the chat_mention db table. Now we want to use that table for other features, so we have to always create a chat_mention record.
2023-03-07 19:07:11 +04:00
Discourse Translator Bot 1f88354c5e
Update translations (#20559) 2023-03-07 14:58:31 +01:00
Joffrey JAFFEUX e27c045f75
PERF: reduce height of the load more past message area (#20545)
On fast networks it could end up in infinite loop until all messages had been loaded.
2023-03-06 17:23:32 +01:00
Joffrey JAFFEUX b5e736504a
PERF: applies optimisations on chat-live pane (#20532)
- group writes when computing separators positions
- shows skeleton only on initial load
- forces date separator to be pinned when first message to prevent a pinned - not pinned - pinned sequence when loading more in past
- relies on `message.visible` property instead of checking `isElementInViewport`
- attempts to load next/prev messages earlier
- do not scroll to on fetch more
- hides `last visit` text while pinned
2023-03-06 16:42:11 +01:00
Joffrey JAFFEUX 9e49abc0b9
FIX: do not refresh when accessing loaded reply (#20526)
Note this test my prove to be flakey, so I might have to remove it or find a different solution. It's extremely complicated to test for something which shouldn't appear in a period of time and is not a present at T=0
2023-03-06 10:09:21 +01:00
chapoi 28f8bdf91d
UX: remove visual chat msg staging effect (#20542) 2023-03-06 10:07:46 +01:00
Joffrey JAFFEUX 1c9f300896
DEV: removes dead code (#20529) 2023-03-03 22:07:40 +01:00
Joffrey JAFFEUX cdcd20fe1e
FIX: prevents duplicate reactions (#20527)
This was possible due to specific events which are hard to represent in a test. The provided test is as close as possible to what was happening in production: a message bus event was played on a channel which has just loaded its state with the existing reaction.
2023-03-03 20:29:24 +01:00
Joffrey JAFFEUX 0dc9c6c96d
FIX: prevents exception on required login sites with chat (#20525)
On require login sites, the `site` is not setup and as a result `hashtag_configurations` was blank and causing an error when attempting to access `["chat-composer"]` on it.
2023-03-03 17:40:23 +01:00
Joffrey JAFFEUX 5d6e8fdff0
UX: makes last visit stand out less (#20524) 2023-03-03 15:55:22 +01:00
Joffrey JAFFEUX 6b0aeced7e
DEV: rework the chat-live-pane (#20519)
This PR is introducing glimmer usage in the chat-live-pane, for components but also for models. RestModel usage has been dropped in favor of native classes.

Other changes/additions in this PR:

sticky dates, scrolling will now keep the date separator of the current section at the top of the screen
better unread management, marking a channel as unread will correctly mark the correct message and not mark the whole channel as read. Tracking state will also now correctly return unread count and unread mentions.
adds an animation on bottom arrow
better scrolling behavior, we should now always correctly keep the scroll position while loading more
reactions are now more reactive, and will update their tooltip without needed to close/reopen it
skeleton has been improved with placeholder images and reactions
when making a reaction on the desktop message actions, the menu won't move anymore
simplify logic and stop maintaining a list of unloaded messages
2023-03-03 13:09:25 +01:00
David Taylor e08a0b509d
DEV: Support `@debounce` decorator in native class syntax (#20521)
The implementation previously generated a descriptor with an `initializer()`, and bound the function to the `this` context of the initializer. In native class syntax, the initializer of a descriptor is only called once, with a `this` context of the constructor, not the instance.

This commit updates the implementation so that it generates the bound function on-demand using a getter. This is the same strategy employed by ember's built-in `@action` decorator.

Unfortunately, this use of a getter means that the `@observes` decorator does not support being directly chained to `@debounce`. It throws the error "`observer must be provided a function or an observer definition`". The workaround is to put the observer on its own function, which then calls the debounced function. Given that we're aiming to reduce our usage of `@observes`, we've accepted the need for this workaround rather than spending the time to patch the implementation of `@observes`.
2023-03-03 11:48:58 +00:00
Kris e022a7adec
UX: update user chat preference link for new nav (#20518) 2023-03-03 06:50:47 +08:00
Joffrey JAFFEUX 435761ef58
Revert "DEV: rework the chat-live-pane (#20511)" (#20514)
This reverts commit 10e1831139.
2023-03-02 20:20:39 +01:00
Joffrey JAFFEUX 10e1831139
DEV: rework the chat-live-pane (#20511)
This PR is introducing glimmer usage in the chat-live-pane, for components but also for models. RestModel usage has been dropped in favor of native classes.

Other changes/additions in this PR:

- sticky dates, scrolling will now keep the date separator of the current section at the top of the screen
- better unread management, marking a channel as unread will correctly mark the correct message and not mark the whole channel as read. Tracking state will also now correctly return unread count and unread mentions.
- adds an animation on bottom arrow
- better scrolling behavior, we should now always correctly keep the scroll position while loading more
- reactions are now more reactive, and will update their tooltip without needed to close/reopen it
- skeleton has been improved with placeholder images and reactions
- when making a reaction on the desktop message actions, the menu won't move anymore
- simplify logic and stop maintaining a list of unloaded messages
2023-03-02 19:46:03 +01:00
Joffrey JAFFEUX 31480bde92
Revert "DEV: rework the chat-live-pane" (#20510)
This reverts commit 67c0498f64.
2023-03-02 16:59:11 +01:00
chapoi e52bbc1230
UX/DEV: Review queue redesign fixes (#20239)
* UX: add type tag and design update

* UX: clarify status copy in reviewQ

* DEV: switch to selectKit

* UX: color approve/reject buttons in RQ

* DEV: regroup actions

* UX: add type tag and design update

* UX: clarify status copy in reviewQ

* Join questions for flagged post with "or" with new I18n function
* Move ReviewableScores component out of context
* Add CSS classes to reviewable-item based on human type

* UX: add table header for scoring

* UX: don't display % score

* UX: prefix modifier class with dash

* UX: reviewQ flag table styling

* UX: consistent use of ignore icon

* DEV: only show context question on pending status

* UX: only show table headers on pending status

* DEV: reviewQ regroup actions for hidden posts

* UX: reviewQ > approve/reject buttons

* UX: reviewQ add fadeout

* UX: reviewQ styling

* DEV: move scores back into component

* UX: reviewQ mobile styling

* UX: score table on mobile

* UX: reviewQ > move meta info outside table

* UX: reviewQ > score layout fixes

* DEV: readd `agree_and_keep` and fix the spec tests.

* Fix the spec tests

* fix the quint test

* DEV: readd deleting replies

* UX: reviewQ copy tweaks

* DEV: readd test for ignore + delete replies

* Remove old

* FIX: Add perform_ignore back in for backwards compat

* DEV: add an action alias `ignore` for `ignore_and_do_nothing`.

---------

Co-authored-by: Martin Brennan <martin@discourse.org>
Co-authored-by: Vinoth Kannan <svkn.87@gmail.com>
2023-03-02 16:40:53 +01:00
Joffrey JAFFEUX 67c0498f64
DEV: rework the chat-live-pane
This PR is introducing glimmer usage in the chat-live-pane, for components but also for models. RestModel usage has been dropped in favor of native classes.

Other changes/additions in this PR:

- sticky dates, scrolling will now keep the date separator of the current section at the top of the screen
- better unread management, marking a channel as unread will correctly mark the correct message and not mark the whole channel as read. Tracking state will also now correctly return unread count and unread mentions.
- adds an animation on bottom arrow
- better scrolling behavior, we should now always correctly keep the scroll position while loading more
- reactions are now more reactive, and will update their tooltip without needed to close/reopen it
- skeleton has been improved with placeholder images and reactions
- when making a reaction on the desktop message actions, the menu won't move anymore
- simplify logic and stop maintaining a list of unloaded messages
2023-03-02 16:34:25 +01:00
Martin Brennan d3a1b09361
FEATURE: Chat header icon indicator preference (#20474)
This commit allows the user to set their preference vis-a-vis
the chat icon in the header of the page. There are three options:

- All New (default) - This maintains the existing behaviour where
  all new messages in the channel show a blue dot on the icon
- Direct Messages and Mentions - Only show the green dot on the
  icon when you are directly messaged or mentioned, the blue dot
  is never shown
- Never - Never show any dot on the chat icon, for those who
  want tractor-beam-laser-focus
2023-03-01 11:01:44 +10:00
Discourse Translator Bot 5138caf525
Update translations (#20478) 2023-02-28 14:48:22 +01:00
Natalie Tay 4855a2879c
UX: Update badge icons (#20462) 2023-02-28 10:42:05 +08:00
Jarek Radosz c81d4f60af
UX: Fix large onebox avatars in img chat messages (#20469)
When you included an image and a full-line (github) onebox in a single message the user avatar in the inbox would be incorrectly embiggened.
2023-02-27 23:03:02 +01:00
Loïc Guitaut bc4e016b49 DEV: Make the `model` step compatible with collections 2023-02-27 14:24:43 +01:00
Andrei Prigorshnev 69c7df2e56
DEV: do not fabricate a Notification when fabricating a ChatMention (#20450)
Initially, the chat_mention db table was created to support notifications. So when creating 
a `chat_mention` record we were always creating a related `notification` record. So did the
ChatMention fabricator. 

Now we want to use the chat_mention db table in other scenarios. So we started decoupling 
mentions from notification in 75b81b68.

This removes fabrication of Notifications from the ChatMention fabricator. We need to be able 
to fabricate a ChatMention without a Notification.
2023-02-27 14:41:28 +04:00
Loïc Guitaut b8762172e4 DEV: Allow `with_service` in jobs
This patch introduces a new `ServiceJob` class allowing the use of
`with_service` in jobs.

This way, it’s easier to use the chat service objects in jobs and
provides the same level of functionality than the one we have in
controllers.
2023-02-23 09:28:53 +01:00
Martin Brennan 74e7ee175b
FIX: Blank dialog when auto-join selected in channel creation modal (#20405)
Fixes issue introduced in 7ef482a292
where the correct warning message was not shown when enabling auto-join
for public categories when creating a channel. Adds more system specs
as well to avoid regressions.
2023-02-22 17:38:54 +10:00
Discourse Translator Bot 76260a4d79
Update translations (#20389) 2023-02-21 17:12:10 +01:00
Loïc Guitaut f7c57fbc19 DEV: Enable `unless` cops
We discussed the use of `unless` internally and decided to enforce
available rules from rubocop to restrict its most problematic uses.
2023-02-21 10:30:48 +01:00
chapoi 87de3c2319
UX: highlight vars updates (#20346)
* UX: replace highlight vars in popup menu

* UX: replace highlight vars in autcomplete

* UX: replace highlight vars in menu-panel

* UX: update style guide

* UX: bulk replace highlight vars in various small appearances
2023-02-21 10:15:49 +01:00
chapoi 8c80d330fa
UX: apply skeleton animation on content only (#20376) 2023-02-20 18:54:00 +01:00
David Taylor 7ed4eaabda
DEV: Update styleguide example titles to use angle-bracket naming (#20375) 2023-02-20 15:16:18 +00:00
Gerhard Schlager 3d7aec36b5
FIX: Wrong interpolation key (#20374)
follow-up to 7ef482a2
2023-02-20 16:03:45 +01:00
Keegan George 9c29d688e7
FEATURE: Add word count and indicator when exceeded max (#19367)
**This PR creates a new core reusable component wraps a character counter around any input.**

The component accepts the arguments: `max` (the maximum character limit), `value` (the value of text to be monitored).

It can be used for example, like so:
```hbs
  <CharCounter @max="50" @value={{this.charCounterContent}}>
    <textarea
      placeholder={{i18n "styleguide.sections.char_counter.placeholder"}}
      {{on "input" (action (mut this.charCounterContent) value="target.value")}}
      class="styleguide--char-counter"></textarea>
  </CharCounter>
```

**This PR also:**
1. Applies this component to the chat plugins edit channel's *Edit Description** modal, thereby replacing the simple text area which provided no visual indication when text exceeded the max allowed characters.
2. Adds an example to the `/styleguide` route
2023-02-20 12:06:43 +01:00
Discourse Translator Bot 43800eeb73
Update translations (#20370) 2023-02-20 11:01:01 +01:00
Gerhard Schlager 7ef482a292
REFACTOR: Fix pluralized strings in chat plugin (#20357)
* FIX: Use pluralized string

* REFACTOR: Fix misuse of pluralized string

* REFACTOR: Fix misuse of pluralized string

* DEV: Remove linting of `one` key in MessageFormat string, it doesn't work

* REFACTOR: Fix misuse of pluralized string

This also ensures that the URL works on subfolder and shows the site setting link only for admins instead of staff. The string is quite complicated, so the best option was to switch to MessageFormat.

* REFACTOR: Fix misuse of pluralized string

* FIX: Use pluralized string

This also ensures that the URL works on subfolder and shows the site setting link only for admins instead of staff.

* REFACTOR: Correctly pluralize reaction tooltips in chat

This also ensures that maximum 5 usernames are shown and fixes the number of "others" which was off by 1 if the current user reacted on a message.

* REFACTOR: Use translatable string as comma separator

* DEV: Add comment to translation to clarify the meaning of `%{identifier}`

* REFACTOR: Use translatable comma separator and use explicit interpolation keys

* REFACTOR: Don't interpolate lowercase channel status

* REFACTOR: Fix misuse of pluralized string

* REFACTOR: Don't interpolate channel status

* REFACTOR: Use %{count} interpolation key

* REFACTOR: Fix misuse of pluralized string

* REFACTOR: Correctly pluralize DM chat channel titles
2023-02-20 10:31:02 +01:00
Joffrey JAFFEUX 39be3cb619
DEV: fixes spec failing with ruby 3.2.1 (#20356)
The error was:

```
Failures:

  1) Chat::Endpoint.call(service, &block) when using the on_failed_contract action when the service contract does not fail does not run the provided block
     Failure/Error: subject(:endpoint) { described_class.call(service, controller, &actions_block) }

     NoMethodError:
       private method `run' called for #<SuccessContractService:0x000000011e3b28a0 @initial_context={"guardian"=>nil}, @context=#<Chat::Service::Base::Context guardian=nil, __steps__=[#<Chat::Service::Base::ContractStep:0x000000011de51230 @name=:default, @method_name=:default, @class_name=SuccessContractService::Contract, @default_values_from=nil>]>>
     # ./plugins/chat/app/services/base.rb:305:in `call'
     # ./plugins/chat/app/helpers/with_service_helper.rb:20:in `run_service'
     # ./plugins/chat/lib/endpoint.rb:76:in `call'
     # ./plugins/chat/lib/endpoint.rb:70:in `call'
     # ./plugins/chat/spec/lib/endpoint_spec.rb:80:in `block (3 levels) in <main>'
     # ./plugins/chat/spec/lib/endpoint_spec.rb:198:in `block (5 levels) in <main>'
     # ./spec/rails_helper.rb:358:in `block (2 levels) in <top (required)>'
```
2023-02-18 12:13:41 +01:00
Joffrey JAFFEUX e797d2082b
UX: contains overscroll in channels list (#20353) 2023-02-18 11:00:02 +01:00
Jarek Radosz 3c6e3173cd
FIX: Glimmer component arg access (#20354)
This regressed in b94fa3b87a as the component was migrated to a glimmer component.
2023-02-18 10:59:28 +01:00
Jarek Radosz 9519747a01
FIX: Correctly update _subscribedTo* props (#20351)
`_subscribedToChat` was previously a never-true, and `_subscribedToCore` once set to false could no longer be flicked back to true.
2023-02-17 21:45:21 +01:00
Joffrey JAFFEUX 8144730ebb
FIX: correctly add user info data to message serializer (#20348)
Previous commit 479c0a3051 was done with the assumption that this info was defined on user serializer but it was actually defined on post serializer in core. This commit extends the user serializer for messages to add this data to the user.

Also correctly adds serializer test to ensure we actually have this data.
2023-02-17 17:07:44 +01:00
Jan Cernik f48e25b215
FIX: Chat member user card rendered out of view (#20332) 2023-02-17 10:14:00 -03:00
Joffrey JAFFEUX a0b83dac86
UX: prevents scroll in chat to propagate to parents (#20347)
Prior to this fix, scrolling in the drawer for example, would also scroll the full page when reaching bottom of available messages.
2023-02-17 13:39:51 +01:00
chapoi 8465f53a35
UX: userstatus limit handling in UI (#20343)
* UX: handle long userstatus in menupanel

* UX: remove margin on userstatus emoji

* UX: change emoji sise of user status in DM creator

* FIX: user status overflow on chat index
2023-02-17 06:54:56 +01:00
Martin Brennan 584d9a9438
DEV: Use service objects for chat thread lookup (#20276)
Adds a new LookupThread class that handles finding the
thread based on thread + channel ID, checking permissions
and policy/contract checks.

Co-authored-by: Loïc Guitaut <loic@discourse.org>
2023-02-16 19:17:26 +01:00
Joffrey JAFFEUX 5ebf016a3f
FIX: removes uneeded footer-nav-height subtraction (#20336)
This was incorrectly added.
2023-02-16 18:25:36 +01:00
Joffrey JAFFEUX eb0caed75a
FIX: ensures staged message are set with channel id (#20335) 2023-02-16 18:05:13 +01:00
Joffrey JAFFEUX 479c0a3051
DEV: adds is-new-user and primary group class (#20322)
This commit also refactors chat-message-info to use glimmer.
2023-02-16 17:17:16 +01:00
Andrei Prigorshnev 75b81b6854
DEV: extract the logic for extracting and expanding mentions from ChatNotifier (#20290)
Initially, the ChatMention model / db table was introduced to better support notifications (see discourse/discourse-chat@0801d10). That means that currently, we create a new chat_mention record only if a user will be notified about the mention.

Now we plan to start using the ChatMention model in other scenarios (for example for implementing user status on mentions) so we need to always create a new record in the chat_mention table. This PR does the first step into that direction by decoupling the logic for extracting and expanding mentions from the code related to notifications.

This doesn't change any behavior, only extracts code from ChatNotifier.
2023-02-16 19:55:18 +04:00
Joffrey JAFFEUX 7391f8e077
FIX: correctly account for ipad footer nav height (#20334)
This code also removes duplicated code in chat which doesn’t seem necessary anymore.
2023-02-16 16:49:17 +01:00
Joffrey JAFFEUX 7cc0c59469
FIX: removes stored scroll position in drawer (#20328) 2023-02-16 12:58:47 +01:00
Martin Brennan 9704d9aed6
DEV: Glimmerize ChatMessageActionsDesktop/Mobile components (#20325)
These are fairly small components, so we can change to using
glimmer without too much trouble.
2023-02-16 11:24:29 +01:00
chapoi 33ee46d62b
UX: update chat draft icon colour (#20326) 2023-02-16 09:16:07 +01:00
Krzysztof Kotlarek 1a5f6aefc7
FIX: correct sidebar and chat height on DiscourseHub (#20323)
Before that change, footer of the sidebar was not visible.
Footer is very important, especially now, when add custom section button is located there.
Also, distance between chat input and keyboard were increased
2023-02-16 15:59:09 +11:00
Martin Brennan c0a086a988
DEV: Move ChatThreadsManager to channel (#20304)
This commit changes the ChatThreadsManager into a native
class instead of an ember service, and initializes it
for every ChatChannel model. This way each channel has its
own thread manager and cache that we can load/unload as
needed, and we also move activeThread to the channel since
it makes more sense to keep it there, not inside the chat service.

The pattern of calling setOwner with the passed in owner
from ChatChannel is adapted from the latest ember docs,
and is needed to avoid the error below when calling services
from the native class:

> Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container

It works well _only_ if we use our own getOwner wrapper
from addon/lib/get-owner, which is for backwards compat.

c.f. https://guides.emberjs.com/release/in-depth-topics/native-classes-in-depth/
2023-02-16 10:00:40 +10:00