Merge pull request #28 from serpi90/admantic-changes

Fixes and merges from other repos
This commit is contained in:
Ryo SUETSUGU
2019-11-30 08:44:49 +08:00
committed by GitHub
2 changed files with 27 additions and 2 deletions

View File

@@ -20,7 +20,9 @@ class WebhookSettingsController < ApplicationController
id = params[:webhook_id]
webhook = Webhook.where(:project_id => @project.id).where(:id => id).first
webhook.url = params[:url]
if webhook.save
if webhook.url.empty?
webhook.destroy
elsif webhook.save
flash[:notice] = l(:notice_successful_update_webhook)
else
flash[:error] = l(:notice_fail_update_webhook)

View File

@@ -15,6 +15,7 @@ module RedmineWebhook
controller = context[:controller]
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, issue_to_json(issue, controller))
end
@@ -26,10 +27,32 @@ 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 controller_issues_bulk_edit_after_save(context = {})
return if skip_webhooks(context)
journal = context[:journal]
controller = context[:controller]
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)
{
@@ -47,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