mirror of
https://github.com/discourse/discourse.git
synced 2026-08-07 03:35:32 -05:00
FIX: new DM channels not being published (#36799)
By setting following to "false" on new DM channels it mirrors what happens when you hit X on a channel, that way the first message will trigger showing the channel to the missing users
This commit is contained in:
@@ -99,7 +99,7 @@ module Chat
|
||||
channel.update!(optional_params) if !optional_params.empty?
|
||||
end
|
||||
|
||||
def create_memberships(channel:, target_users:)
|
||||
def create_memberships(channel:, target_users:, guardian:)
|
||||
always_level = ::Chat::UserChatChannelMembership::NOTIFICATION_LEVELS[:always]
|
||||
|
||||
memberships =
|
||||
@@ -108,7 +108,7 @@ module Chat
|
||||
user_id: user.id,
|
||||
chat_channel_id: channel.id,
|
||||
muted: false,
|
||||
following: true,
|
||||
following: user.id == guardian.user.id,
|
||||
notification_level: always_level,
|
||||
created_at: Time.zone.now,
|
||||
updated_at: Time.zone.now,
|
||||
|
||||
@@ -63,8 +63,9 @@ RSpec.describe Chat::CreateDirectMessageChannel do
|
||||
[current_user.id, user_1.id, user_2.id],
|
||||
)
|
||||
result.channel.user_chat_channel_memberships.each do |membership|
|
||||
should_follow = membership.user_id == current_user.id
|
||||
expect(membership).to have_attributes(
|
||||
following: true,
|
||||
following: should_follow,
|
||||
muted: false,
|
||||
notification_level: "always",
|
||||
)
|
||||
|
||||
@@ -164,6 +164,33 @@ RSpec.describe "Message notifications - with sidebar", type: :system do
|
||||
end
|
||||
end
|
||||
|
||||
context "when a new direct message channel is created" do
|
||||
fab!(:other_user, :user)
|
||||
let!(:chat_sidebar) { PageObjects::Components::Chat::Sidebar.new }
|
||||
|
||||
it "shows the channel in the sidebar without reload" do
|
||||
visit("/")
|
||||
|
||||
expect(chat_sidebar).to have_start_new_dm
|
||||
|
||||
result =
|
||||
Chat::CreateDirectMessageChannel.call(
|
||||
guardian: other_user.guardian,
|
||||
params: {
|
||||
target_usernames: [current_user.username],
|
||||
},
|
||||
)
|
||||
service_failed!(result) if result.failure?
|
||||
|
||||
dm_channel = result.channel
|
||||
|
||||
create_message(channel: dm_channel, creator: other_user)
|
||||
|
||||
expect(chat_sidebar).to have_direct_message_channel(dm_channel)
|
||||
expect(chat_sidebar).to have_no_start_new_dm
|
||||
end
|
||||
end
|
||||
|
||||
context "with dm channel" do
|
||||
fab!(:current_user, :admin)
|
||||
fab!(:user_1, :user)
|
||||
|
||||
Reference in New Issue
Block a user