mirror of
https://github.com/dolphin-emu/redmine_webhook.git
synced 2026-01-31 01:15:19 +01:00
Added: issues URL
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user