Issue assignee data should be posted to webhook
Currently, only the assignee_id is available. It would be nice if the posted data would also contain the name and username of the assignee. This would improve integration with for example kanboard.
I don't "speak" ruby. But I managed to add these lines to app/services/issues/base_service.rb in def hook_data:
assignee = User.find(issue.assignee_id)
# and if assignee data could be found:
issue_data[:object_attributes].merge!(assignee: assignee.hook_attrs)
Which results in the following sample output:
(
[object_kind] => issue
[user] => Array
(
[name] => Administrator
[username] => root
[avatar_url] => http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=40&d=identicon
)
[repository] => Array
(
[name] => Flight
[url] => bram@localhost:twitter/flight.git
[description] => Quisquam tenetur aut vel sunt voluptate quidem.
[homepage] => http://localhost:3000/twitter/flight
)
[object_attributes] => Array
(
[id] => 81
[title] => fdfsd
[assignee_id] => 16
[author_id] => 1
[project_id] => 6
[created_at] => 2015-10-13 20:41:29 UTC
[updated_at] => 2015-10-13 22:54:24 UTC
[position] => 0
[branch_name] =>
[description] => dfsdfs
[milestone_id] =>
[state] => opened
[iid] => 11
[updated_by_id] => 1
[assignee] => Array
(
[name] => Forrest Cruickshank
[username] => deron_blick
[avatar_url] => http://www.gravatar.com/avatar/c9e06e4efa3eb53f008bba36ca154989?s=40&d=identicon
)
[url] => http://localhost:3000/twitter/flight/issues/11
[action] => update
)
)
Now, since i could not come up with a check to see if there is an assignee, it fails horribly in case no user is assigned ;-) Tried "if assignee.exists?
", "if assignee
" and some other tests before giving up.
Somebody here should know how to fix that!
Bests,
Bram