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. -->
This commit is contained in:
Joffrey JAFFEUX
2023-03-17 14:24:38 +01:00
committed by GitHub
parent 74349e17c9
commit 12a18d4d55
343 changed files with 9077 additions and 8745 deletions

View File

@ -54,7 +54,10 @@ describe UserNotifications do
user: another_participant,
chat_channel: channel,
)
DirectMessageUser.create!(direct_message: channel.chatable, user: another_participant)
Chat::DirectMessageUser.create!(
direct_message: channel.chatable,
user: another_participant,
)
expected_subject =
I18n.t(
"user_notifications.chat_summary.subject.direct_message_from_1",
@ -168,7 +171,7 @@ describe UserNotifications do
# Sometimes it's not enough to just fabricate a message
# and we have to create it like here. In this case all the necessary
# db records for mentions and notifications will be created under the hood.
Chat::ChatMessageCreator.create(chat_channel: channel, user: sender, content: content)
Chat::MessageCreator.create(chat_channel: channel, user: sender, content: content)
end
it "returns email for @all mention by default" do