Merge pull request #2245 from wbso-ai/extend-slack-message

Add link to Fizzy card in Slack message
This commit is contained in:
Jorge Manrubia
2026-01-07 16:37:51 +01:00
committed by GitHub
2 changed files with 20 additions and 3 deletions
+5 -1
View File
@@ -14,7 +14,7 @@ class Event::Description
end
def to_plain_text
to_sentence(creator_name, h(card.title))
to_sentence(creator_name, quoted(card.title))
end
private
@@ -41,6 +41,10 @@ class Event::Description
h(event.creator.name)
end
def quoted(text)
%("#{h text}")
end
def card
@card ||= event.action.comment_created? ? event.eventable.card : event.eventable
end
+15 -2
View File
@@ -1,4 +1,6 @@
class Webhook::Delivery < ApplicationRecord
include Rails.application.routes.url_helpers
class ResponseTooLarge < StandardError; end
STALE_TRESHOLD = 7.days
@@ -130,8 +132,7 @@ class Webhook::Delivery < ApplicationRecord
elsif webhook.for_campfire?
render_payload(formats: :html)
elsif webhook.for_slack?
html = render_payload(formats: :html)
{ text: convert_html_to_mrkdwn(html) }.to_json
slack_payload
else
render_payload(formats: :json)
end
@@ -158,4 +159,16 @@ class Webhook::Delivery < ApplicationRecord
document.text
end
def slack_payload
text = event.description_for(nil).to_plain_text
url = polymorphic_url(event.eventable, base_url_options.merge(script_name: account.slug))
{ text: "#{text} <#{url}|Open in Fizzy>" }.to_json
end
def base_url_options
Rails.application.routes.default_url_options.presence ||
Rails.application.config.action_mailer.default_url_options
end
end