Added: issues URL

This commit is contained in:
suer
2014-03-02 00:39:04 +09:00
parent 7b84b13a5a
commit 64464d2f9c

View File

@@ -1,37 +1,41 @@
class RedmineWebhook::WebhookListener < Redmine::Hook::Listener
def controller_issues_new_after_save(context = {})
issue = context[:issue]
controller = context[:controller]
project = issue.project
webhook = Webhook.where(:project_id => project.project.id).first
return unless webhook
post(webhook, issue_to_json(issue))
post(webhook, issue_to_json(issue, controller))
end
def controller_issues_edit_after_save(context = {})
journal = context[:journal]
controller = context[:controller]
issue = context[:issue]
project = issue.project
webhook = Webhook.where(:project_id => project.project.id).first
return unless webhook
post(webhook, journal_to_json(issue, journal))
post(webhook, journal_to_json(issue, journal, controller))
end
private
def issue_to_json(issue)
def issue_to_json(issue, controller)
{
:payload => {
:action => 'opened',
:issue => RedmineWebhook::IssueWrapper.new(issue).to_hash
:issue => RedmineWebhook::IssueWrapper.new(issue).to_hash,
:url => controller.issue_url(issue)
}
}.to_json
end
def journal_to_json(issue, journal)
def journal_to_json(issue, journal, controller)
{
:payload => {
:action => 'updated',
:issue => RedmineWebhook::IssueWrapper.new(issue).to_hash,
:journal => RedmineWebhook::JournalWrapper.new(journal).to_hash
:journal => RedmineWebhook::JournalWrapper.new(journal).to_hash,
:url => controller.issue_url(issue)
}
}.to_json
end