mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 20:51:08 +08:00
DEV: Rename direct message related models
This is a followup of the previous refactor where we created two new models to handle all the dedicated logic that was present in the `ChatChannel` model. For the sake of consistency, `DMChannel` has been renamed to `DirectMessageChannel` and the previous `DirectMessageChannel` model is now named `DirectMessage`. This should help reasoning about direct messages.
This commit is contained in:

committed by
Loïc Guitaut

parent
7e992cb299
commit
abcaa1a961
@ -129,7 +129,7 @@ class Chat::ChatChannelsController < Chat::ChatBaseController
|
||||
if users.count > 0
|
||||
ChatChannel
|
||||
.includes(chatable: :users)
|
||||
.joins(direct_message_channel: :direct_message_users)
|
||||
.joins(direct_message: :direct_message_users)
|
||||
.group(1)
|
||||
.having(
|
||||
"ARRAY[?] <@ ARRAY_AGG(user_id) AND ARRAY[?] && ARRAY_AGG(user_id)",
|
||||
|
@ -25,13 +25,9 @@ class Chat::DirectMessagesController < Chat::ChatBaseController
|
||||
guardian.ensure_can_chat!(current_user)
|
||||
users = users_from_usernames(current_user, params)
|
||||
|
||||
direct_message_channel = DirectMessageChannel.for_user_ids(users.map(&:id).uniq)
|
||||
if direct_message_channel
|
||||
chat_channel =
|
||||
ChatChannel.find_by(
|
||||
chatable_id: direct_message_channel.id,
|
||||
chatable_type: "DirectMessageChannel",
|
||||
)
|
||||
direct_message = DirectMessage.for_user_ids(users.map(&:id).uniq)
|
||||
if direct_message
|
||||
chat_channel = ChatChannel.find_by(chatable: direct_message)
|
||||
render_serialized(
|
||||
chat_channel,
|
||||
ChatChannelSerializer,
|
||||
|
Reference in New Issue
Block a user