|
|
|
@@ -30,6 +30,11 @@ class Api::V1::Issues::UpdateService < ApplicationService |
|
|
|
@before_assigner_ids = issue.assigners.pluck(:id) |
|
|
|
@attachment_ids = params[:attachment_ids] |
|
|
|
@receivers_login = params[:receivers_login] |
|
|
|
@pm_project_id = params[:pm_project_id] |
|
|
|
@pm_sprint_id = params[:pm_sprint_id] |
|
|
|
@pm_issue_type = params[:pm_issue_type] |
|
|
|
@parent_id = params[:parent_id] |
|
|
|
@time_scale = params[:time_scale] |
|
|
|
@add_assigner_ids = [] |
|
|
|
@previous_issue_changes = {} |
|
|
|
end |
|
|
|
@@ -68,28 +73,34 @@ class Api::V1::Issues::UpdateService < ApplicationService |
|
|
|
@updated_issue.issue_tags_relates.destroy_all & @updated_issue.issue_tags = @issue_tags || IssueTag.none unless issue_tag_ids.nil? |
|
|
|
@updated_issue.issue_tags_value = @issue_tags.order("id asc").pluck(:id).join(",") unless issue_tag_ids.nil? |
|
|
|
|
|
|
|
@created_issue.pm_project_id = @pm_project_id |
|
|
|
@created_issue.pm_sprint_id = @pm_sprint_id |
|
|
|
@created_issue.pm_issue_type = @pm_issue_type |
|
|
|
@created_issue.parent_id = @parent_id |
|
|
|
@created_issue.time_scale = @time_scale |
|
|
|
|
|
|
|
@updated_issue.updated_on = Time.now |
|
|
|
@updated_issue.save! |
|
|
|
|
|
|
|
build_after_issue_journal_details if @updated_issue.previous_changes.present? # 操作记录 |
|
|
|
build_previous_issue_changes |
|
|
|
build_cirle_blockchain_token if blockchain_token_num.present? |
|
|
|
unless project.id.zero? |
|
|
|
# @信息发送 |
|
|
|
AtmeService.call(current_user, @atme_receivers, @issue) unless receivers_login.blank? |
|
|
|
# 消息发送 |
|
|
|
if Site.has_notice_menu? |
|
|
|
SendTemplateMessageJob.perform_later('IssueChanged', current_user.id, @issue&.id, previous_issue_changes) unless previous_issue_changes.blank? |
|
|
|
SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @issue&.id, add_assigner_ids) unless add_assigner_ids.blank? |
|
|
|
end |
|
|
|
|
|
|
|
# @信息发送 |
|
|
|
AtmeService.call(current_user, @atme_receivers, @issue) unless receivers_login.blank? |
|
|
|
# 消息发送 |
|
|
|
if Site.has_notice_menu? |
|
|
|
SendTemplateMessageJob.perform_later('IssueChanged', current_user.id, @issue&.id, previous_issue_changes) unless previous_issue_changes.blank? |
|
|
|
SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @issue&.id, add_assigner_ids) unless add_assigner_ids.blank? |
|
|
|
unlock("Api::V1::Issues::UpdateService:#{project.id}:#{issue.id}") |
|
|
|
# 触发webhook |
|
|
|
Rails.logger.info "################### 触发webhook" |
|
|
|
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? |
|
|
|
end |
|
|
|
|
|
|
|
unlock("Api::V1::Issues::UpdateService:#{project.id}:#{issue.id}") |
|
|
|
# 触发webhook |
|
|
|
Rails.logger.info "################### 触发webhook" |
|
|
|
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? |
|
|
|
|
|
|
|
return @updated_issue |
|
|
|
end |
|
|
|
end |
|
|
|
|