Commit 45e1941f authored by Jeroen van Baarsen's avatar Jeroen van Baarsen

Return a little more information in Issue webhook

When a webhook for issues is triggered, it should also return the
resource URL, and the action that was performed (ie: Was it reopened,
updated, opened or closed)
parent a5cbb4cb
module Issues module Issues
class BaseService < ::BaseService class BaseService < ::BaseService
include Rails.application.routes.url_helpers
private private
...@@ -7,8 +8,13 @@ module Issues ...@@ -7,8 +8,13 @@ module Issues
Note.create_assignee_change_note(issue, issue.project, current_user, issue.assignee) Note.create_assignee_change_note(issue, issue.project, current_user, issue.assignee)
end end
def execute_hooks(issue) def execute_hooks(issue, action = 'open')
issue.project.execute_hooks(issue.to_hook_data, :issue_hooks) issue_data = issue.to_hook_data
issue_url = project_issue_url(id: issue.iid,
project_id: issue.project,
host: Settings.gitlab['url'])
issue_data[:object_attributes].merge!(url: issue_url, action: action)
issue.project.execute_hooks(issue_data, :issue_hooks)
end end
def create_milestone_note(issue) def create_milestone_note(issue)
......
...@@ -5,7 +5,7 @@ module Issues ...@@ -5,7 +5,7 @@ module Issues
notification_service.close_issue(issue, current_user) notification_service.close_issue(issue, current_user)
event_service.close_issue(issue, current_user) event_service.close_issue(issue, current_user)
create_note(issue, commit) create_note(issue, commit)
execute_hooks(issue) execute_hooks(issue, 'close')
end end
issue issue
......
...@@ -8,7 +8,7 @@ module Issues ...@@ -8,7 +8,7 @@ module Issues
notification_service.new_issue(issue, current_user) notification_service.new_issue(issue, current_user)
event_service.open_issue(issue, current_user) event_service.open_issue(issue, current_user)
issue.create_cross_references!(issue.project, current_user) issue.create_cross_references!(issue.project, current_user)
execute_hooks(issue) execute_hooks(issue, 'open')
end end
issue issue
......
...@@ -4,7 +4,7 @@ module Issues ...@@ -4,7 +4,7 @@ module Issues
if issue.reopen if issue.reopen
event_service.reopen_issue(issue, current_user) event_service.reopen_issue(issue, current_user)
create_note(issue) create_note(issue)
execute_hooks(issue) execute_hooks(issue, 'reopen')
end end
issue issue
......
...@@ -23,7 +23,7 @@ module Issues ...@@ -23,7 +23,7 @@ module Issues
end end
issue.notice_added_references(issue.project, current_user) issue.notice_added_references(issue.project, current_user)
execute_hooks(issue) execute_hooks(issue, 'update')
end end
issue issue
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment