A platform for community discussion. Free, open, simple.
FIX: Use hashtags in channel archive PMs if available (#19859)
Martin Brennan2eb0a300b683
diff --git a/plugins/chat/config/locales/server.en.yml b/plugins/chat/config/locales/server.en.ymlindex 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.rbindex 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::ChatChannelArchiveServicedef 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::ChatChannelArchiveServicedef kick_all_usersChat::ChatChannelMembershipManager.new(chat_channel).unfollow_all_usersend++ def channel_hashtag_or_name+ if chat_channel.slug.present? && SiteSetting.enable_experimental_hashtag_autocomplete+ return "##{chat_channel.slug}::channel"+ end+ chat_channel_title+ endenddiff --git a/plugins/chat/spec/lib/chat_channel_archive_service_spec.rb b/plugins/chat/spec/lib/chat_channel_archive_service_spec.rbindex 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 dolet(: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" dobefore { 3.times { Fabricate(:chat_message, chat_channel: channel) } }@@ -184,6 +186,20 @@ describe Chat::ChatChannelArchiveService doexpect(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(+ "<a class=\"hashtag-cooked\" href=\"#{channel.relative_url}\" data-type=\"channel\" data-slug=\"#{channel.slug}\" data-ref=\"#{channel.slug}::channel\"><svg class=\"fa d-icon d-icon-comment svg-icon svg-node\"><use href=\"#comment\"></use></svg><span>#{channel.title(user)}</span></a>",+ )+ end+ end+describe "channel members" dobefore docreate_messages(3)