diff --git a/plugins/chat/config/locales/server.en.yml b/plugins/chat/config/locales/server.en.yml index 9cdaf1c2d68..f0c8abefb9d 100644 --- a/plugins/chat/config/locales/server.en.yml +++ b/plugins/chat/config/locales/server.en.yml @@ -29,17 +29,17 @@ en: title: "Chat Channel Archive Complete" subject_template: "Chat channel archive completed successfully" text_body_template: | - Archiving the chat channel **\#%{channel_name}** has been completed successfully. The messages were copied into the topic [%{topic_title}](%{topic_url}). + Archiving the chat channel %{channel_hashtag_or_name} has been completed successfully. The messages were copied into the topic [%{topic_title}](%{topic_url}). chat_channel_archive_failed: title: "Chat Channel Archive Failed" subject_template: "Chat channel archive failed" text_body_template: | - Archiving the chat channel **\#%{channel_name}** has failed. %{messages_archived} messages have been archived. Partially archived messages were copied into the topic [%{topic_title}](%{topic_url}). Visit the channel at %{channel_url} to retry. + Archiving the chat channel %{channel_hashtag_or_name} has failed. %{messages_archived} messages have been archived. Partially archived messages were copied into the topic [%{topic_title}](%{topic_url}). Visit the channel at %{channel_url} to retry. chat_channel_archive_failed_no_topic: title: "Chat Channel Archive Failed" subject_template: "Chat channel archive failed" text_body_template: | - Archiving the chat channel **\#%{channel_name}** has failed. No messages have been archived. The topic was not created successfully for the following reasons: + Archiving the chat channel %{channel_hashtag_or_name} has failed. No messages have been archived. The topic was not created successfully for the following reasons: %{topic_validation_errors} diff --git a/plugins/chat/lib/chat_channel_archive_service.rb b/plugins/chat/lib/chat_channel_archive_service.rb index 0cd7a9c1d2b..cf656ef4cac 100644 --- a/plugins/chat/lib/chat_channel_archive_service.rb +++ b/plugins/chat/lib/chat_channel_archive_service.rb @@ -248,7 +248,7 @@ class Chat::ChatChannelArchiveService def notify_archiver(result, error_message: nil) base_translation_params = { - channel_name: chat_channel_title, + channel_hashtag_or_name: channel_hashtag_or_name, topic_title: chat_channel_archive.destination_topic&.title, topic_url: chat_channel_archive.destination_topic&.url, topic_validation_errors: result == :failed_no_topic ? error_message : nil, @@ -301,4 +301,11 @@ class Chat::ChatChannelArchiveService def kick_all_users Chat::ChatChannelMembershipManager.new(chat_channel).unfollow_all_users end + + def channel_hashtag_or_name + if chat_channel.slug.present? && SiteSetting.enable_experimental_hashtag_autocomplete + return "##{chat_channel.slug}::channel" + end + chat_channel_title + end end diff --git a/plugins/chat/spec/lib/chat_channel_archive_service_spec.rb b/plugins/chat/spec/lib/chat_channel_archive_service_spec.rb index 2d79e85690e..d42c0f3d1a9 100644 --- a/plugins/chat/spec/lib/chat_channel_archive_service_spec.rb +++ b/plugins/chat/spec/lib/chat_channel_archive_service_spec.rb @@ -12,6 +12,8 @@ describe Chat::ChatChannelArchiveService do let(:topic_params) { { topic_title: "This will be a new topic", category_id: category.id } } subject { Chat::ChatChannelArchiveService } + before { SiteSetting.chat_enabled = true } + describe "#create_archive_process" do before { 3.times { Fabricate(:chat_message, chat_channel: channel) } } @@ -184,6 +186,20 @@ describe Chat::ChatChannelArchiveService do expect(pm_topic.first_post.raw).to include("Title can't have more than 1 emoji") end + context "when enable_experimental_hashtag_autocomplete" do + before { SiteSetting.enable_experimental_hashtag_autocomplete = true } + + it "uses the channel slug to autolink a hashtag for the channel in the PM" do + create_messages(3) && start_archive + subject.new(@channel_archive).execute + expect(@channel_archive.reload.complete?).to eq(true) + pm_topic = Topic.private_messages.last + expect(pm_topic.first_post.cooked).to include( + "#{channel.title(user)}", + ) + end + end + describe "channel members" do before do create_messages(3)