更改:webhook更新返回结构体

This commit is contained in:
2023-04-12 18:34:49 +08:00
parent f64afb8f55
commit 4bd60d458e
7 changed files with 59 additions and 15 deletions

View File

@@ -5,7 +5,7 @@ class Api::V1::Issues::UpdateService < ApplicationService
attr_reader :project, :issue, :current_user
attr_reader :status_id, :priority_id, :milestone_id, :branch_name, :start_date, :due_date, :subject, :description
attr_reader :issue_tag_ids, :assigner_ids, :attachment_ids, :receivers_login
attr_reader :issue_tag_ids, :assigner_ids, :attachment_ids, :receivers_login, :before_issue_tag_ids, :before_assigner_ids
attr_accessor :add_assigner_ids, :previous_issue_changes, :updated_issue, :atme_receivers
validates :project, :issue, :current_user, presence: true
@@ -24,6 +24,8 @@ class Api::V1::Issues::UpdateService < ApplicationService
@description = params[:description]
@issue_tag_ids = params[:issue_tag_ids]
@assigner_ids = params[:assigner_ids]
@before_issue_tag_ids = issue.issue_tags.pluck(:id)
@before_assigner_ids = issue.assigners.pluck(:id)
@attachment_ids = params[:attachment_ids]
@receivers_login = params[:receivers_login]
@add_assigner_ids = []
@@ -78,9 +80,10 @@ class Api::V1::Issues::UpdateService < ApplicationService
end
# 触发webhook
TouchWebhookJob.perform_later('IssueUpdate', @updated_issue&.id, current_user.id, previous_issue_changes.except(:issue_tags_value, :assigned_to_id))
TouchWebhookJob.perform_later('IssueLabel', @updated_issue&.id, current_user.id, issue_tag_ids) unless issue_tag_ids.nil?
TouchWebhookJob.perform_later('IssueAssign', @updated_issue&.id, current_user.id, assigner_ids) unless assigner_ids.nil?
TouchWebhookJob.set(wait: 5.seconds).perform_later('IssueUpdate', @updated_issue&.id, current_user.id, previous_issue_changes.except(:issue_tags_value, :assigned_to_id))
TouchWebhookJob.set(wait: 5.seconds).perform_later('IssueLabel', @issue&.id, current_user.id, {issue_tag_ids: [before_issue_tag_ids, issue_tag_ids]}) unless issue_tag_ids.nil?
TouchWebhookJob.set(wait: 5.seconds).perform_later('IssueAssign', @issue&.id, current_user.id, {assigner_ids: [before_assigner_ids, assigner_ids]}) unless assigner_ids.nil?
unlock("Api::V1::Issues::UpdateService:#{project.id}:#{issue.id}")
return @updated_issue