From 1340d83fc09ebcb2557433c36993a4afcc8c59af Mon Sep 17 00:00:00 2001 From: cat_in_136 Date: Thu, 31 Jan 2019 01:52:01 +0900 Subject: [PATCH] some custom field value in slack posts is not unformatted (#137) * fix custom field formatting * fix regression bug where NilReferenceError raised if a custom field value is nil * fix indent --- lib/redmine_slack/listener.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/redmine_slack/listener.rb b/lib/redmine_slack/listener.rb index 13b3b7e..240a9a6 100644 --- a/lib/redmine_slack/listener.rb +++ b/lib/redmine_slack/listener.rb @@ -215,12 +215,16 @@ def channel_for_project(proj) end def detail_to_field(detail) - if detail.property == "cf" - key = CustomField.find(detail.prop_key).name rescue nil + case detail.property + when "cf" + custom_field = detail.custom_field + key = custom_field.name title = key - elsif detail.property == "attachment" + value = (detail.value)? IssuesController.helpers.format_value(detail.value, custom_field) : "" + when "attachment" key = "attachment" title = I18n.t :label_attachment + value = escape detail.value.to_s else key = detail.prop_key.to_s.sub("_id", "") if key == "parent" @@ -228,10 +232,10 @@ def detail_to_field(detail) else title = I18n.t "field_#{key}" end + value = escape detail.value.to_s end short = true - value = escape detail.value.to_s case key when "title", "subject", "description"