Merge pull request #3 from AdmanTIC/fixes/1038/commit-fixes-send-webhook

Added: emit webhook when fetching changeset
This commit is contained in:
Benjamin MALYNOVYTCH
2017-10-06 14:50:29 +02:00
committed by GitHub

View File

@@ -39,10 +39,20 @@ module RedmineWebhook
issue = context[:issue]
project = issue.project
webhooks = Webhook.where(:project_id => project.project.id)
webhooks = Webhook.where(:project_id => 0) unless webhooks && webhooks.length > 0
return unless webhooks
post(webhooks, journal_to_json(issue, journal, controller))
end
def model_changeset_scan_commit_for_issue_ids_pre_issue_update(context = {})
issue = context[:issue]
journal = issue.current_journal
webhooks = Webhook.where(:project_id => issue.project.project.id)
webhooks = Webhook.where(:project_id => 0) unless webhooks && webhooks.length > 0
return unless webhooks
post(webhooks, journal_to_json(issue, journal, nil))
end
private
def issue_to_json(issue, controller)
{
@@ -60,7 +70,7 @@ module RedmineWebhook
:action => 'updated',
:issue => RedmineWebhook::IssueWrapper.new(issue).to_hash,
:journal => RedmineWebhook::JournalWrapper.new(journal).to_hash,
:url => controller.issue_url(issue)
:url => controller.nil? ? 'not yet implemented' : controller.issue_url(issue)
}
}.to_json
end