Skip to content

Commit

Permalink
some custom field value in slack posts is not unformatted (#137)
Browse files Browse the repository at this point in the history
* fix custom field formatting

* fix regression bug where NilReferenceError raised if a custom field value is nil

* fix indent
  • Loading branch information
cat-in-136 authored and sciyoshi committed Jan 30, 2019
1 parent 7a0eacd commit 1340d83
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/redmine_slack/listener.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,23 +215,27 @@ 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"
title = I18n.t "field_#{key}_issue"
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"
Expand Down

0 comments on commit 1340d83

Please sign in to comment.