FEATURE: Allow `[quote]` to be disabled for slack transcripts (#120)

https://meta.discourse.org/t/222145
This commit is contained in:
David Taylor 2022-04-01 13:49:34 +01:00 committed by GitHub
parent 3900586557
commit cd6e4a8b62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 2 deletions

View File

@ -14,6 +14,7 @@ en:
chat_integration_slack_excerpt_length: 'Slack post excerpt length'
chat_integration_slack_icon_url: 'Icon to post to slack with (defaults to forum logo)'
chat_integration_slack_outbound_webhook_url: "For using Slack's 'Incoming Webhook' system instead of of the OAuth API. Not recommended."
chat_integration_slack_transcript_quote: Wrap slack transcript in [quote] tags?
errors:
chat_integration_slack_api_configs_are_empty: "You must enter either an outbound webhook URL, or an access token"

View File

@ -26,6 +26,8 @@ chat_integration:
regex: '^https:\/\/hooks\.slack\.com\/services\/.+$'
chat_integration_slack_icon_url:
default: ''
chat_integration_slack_transcript_quote:
default: true
#######################################
######### TELEGRAM SETTINGS ###########

View File

@ -82,7 +82,8 @@ module DiscourseChatIntegration::Provider::SlackProvider
end
def build_transcript
post_content = +"[quote]\n"
post_content = +""
post_content << "[quote]\n" if SiteSetting.chat_integration_slack_transcript_quote
post_content << "[**#{I18n.t('chat_integration.provider.slack.transcript.view_on_slack', name: @channel_name)}**](#{first_message.url})\n"
all_avatars = {}
@ -114,7 +115,8 @@ module DiscourseChatIntegration::Provider::SlackProvider
post_content << "\n"
end
post_content << "[/quote]\n\n"
post_content << "[/quote]" if SiteSetting.chat_integration_slack_transcript_quote
post_content << "\n\n"
all_avatars.each do |username, url|
post_content << "[#{username}]: #{url}\n"

View File

@ -317,6 +317,20 @@ RSpec.describe DiscourseChatIntegration::Provider::SlackProvider::SlackTranscrip
expect(text).to eq(expected)
end
it 'omits quote tags when disabled' do
transcript.set_last_message_by_index(1)
text = transcript.build_transcript
expect(text).to include("[quote]")
expect(text).to include("[/quote]")
SiteSetting.chat_integration_slack_transcript_quote = false
text = transcript.build_transcript
expect(text).not_to include("[quote]")
expect(text).not_to include("[/quote]")
end
it 'creates the slack UI correctly' do
transcript.set_last_message_by_index(1)
ui = transcript.build_slack_ui