fix
This commit is contained in:
parent
228becfe07
commit
18b0c76082
|
@ -93,8 +93,6 @@ class PullRequestsController < ApplicationController
|
|||
end
|
||||
|
||||
if @issue.update_attributes(@issue_params)
|
||||
SendTemplateMessageJob.perform_later('PullRequestChanged', current_user.id, @pull_request&.id, @issue.previous_changes.slice(:assigned_to_id, :priority_id, :fixed_version_id, :issue_tags_value))
|
||||
SendTemplateMessageJob.perform_later('PullRequestAssigned', current_user.id, @pull_request&.id ) if @issue.previous_changes[:assigned_to_id].present?
|
||||
if @pull_request.update_attributes(@local_params.compact)
|
||||
gitea_pull = Gitea::PullRequest::UpdateService.call(@owner.login, @repository.identifier,
|
||||
@pull_request.gitea_number, @requests_params, current_user.gitea_token)
|
||||
|
@ -120,6 +118,8 @@ class PullRequestsController < ApplicationController
|
|||
normal_status(-1, e.message)
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
SendTemplateMessageJob.perform_later('PullRequestChanged', current_user.id, @pull_request&.id, @issue.previous_changes.slice(:assigned_to_id, :priority_id, :fixed_version_id, :issue_tags_value))
|
||||
SendTemplateMessageJob.perform_later('PullRequestAssigned', current_user.id, @pull_request&.id ) if @issue.previous_changes[:assigned_to_id].present?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -156,8 +156,9 @@ class SendTemplateMessageJob < ApplicationJob
|
|||
operator_id, pull_request_id = args[0], args[1]
|
||||
operator = User.find_by_id(operator_id)
|
||||
pull_request = PullRequest.find_by_id(pull_request_id)
|
||||
return unless operator.present? && pull_request.present?
|
||||
receivers = User.where(id: pull_request&.issue&.assigned_to_id).where.not(id: operator&.id)
|
||||
issue = Issue.find_by_id(pull_request&.issue_id)
|
||||
return unless operator.present? && pull_request.present? && issue.present?
|
||||
receivers = User.where(id: issue&.assigned_to_id).where.not(id: operator&.id)
|
||||
receivers_string, content, notification_url = MessageTemplate::PullRequestAssigned.get_message_content(receivers, operator, pull_request)
|
||||
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, pull_request_id: pull_request.id})
|
||||
when 'PullRequestAtme'
|
||||
|
@ -172,8 +173,9 @@ class SendTemplateMessageJob < ApplicationJob
|
|||
operator_id, pull_request_id, change_params = args[0], args[1], args[2]
|
||||
operator = User.find_by_id(operator_id)
|
||||
pull_request = PullRequest.find_by_id(pull_request_id)
|
||||
return unless operator.present? && pull_request.present?
|
||||
receivers = User.where(id: [pull_request&.issue&.assigned_to_id, pull_request&.user_id]).where.not(id: operator&.id)
|
||||
issue = Issue.find_by_id(pull_request&.issue_id)
|
||||
return unless operator.present? && pull_request.present? && issue.present?
|
||||
receivers = User.where(id: [issue&.assigned_to_id, pull_request&.user_id]).where.not(id: operator&.id)
|
||||
receivers_string, content, notification_url = MessageTemplate::PullRequestChanged.get_message_content(receivers, operator, pull_request, change_params.symbolize_keys)
|
||||
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, pull_request_id: pull_request.id, change_params: change_params})
|
||||
when 'PullRequestClosed'
|
||||
|
|
|
@ -46,7 +46,7 @@ class MessageTemplate <ApplicationRecord
|
|||
self.create(type: 'MessageTemplate::PullRequestChanged', sys_notice: '在项目{nickname2}/{repository}的合并请求<b>{title}</b>中:{ifassigner}{nickname1}将审查成员从<b>{assigner1}</b>修改为<b>{assigner2}</b>{endassigner}{ifmilestone}{nickname1}将里程碑从<b>{milestone1}</b>修改为<b>{milestone2}</b>{endmilestone}{iftag}{nickname1}将标记从<b>{tag1}</b>修改为<b>{tag2}</b>{endtag}{ifpriority}{nickname1}将优先级从<b>{priority1}</b>修改为<b>{priority2}</b>{endpriority}', notification_url: '{baseurl}/{owner}/{identifier}/pulls/{id}/Messagecount')
|
||||
self.create(type: 'MessageTemplate::PullRequestClosed', sys_notice: '你提交的合并请求:{title}被拒绝', notification_url: '')
|
||||
self.create(type: 'MessageTemplate::PullRequestJournal', sys_notice: '{nickname}评论合并请求{title}:<b>{notes}</b>', notification_url: '{baseurl}/{owner}/{identifier}/pulls/{id}/Messagecount')
|
||||
self.create(type: 'MessageTemplate::PullRequestMerged', sys_notice: '你提交的合并请求:{title}被合并', notification_url: '{baseurl}/{owner}/{identifier}/pulls/{id}/Messagecount')
|
||||
self.create(type: 'MessageTemplate::PullRequestMerged', sys_notice: '你提交的合并请求:{title}已通过', notification_url: '{baseurl}/{owner}/{identifier}/pulls/{id}/Messagecount')
|
||||
end
|
||||
|
||||
def self.sys_notice
|
||||
|
|
|
@ -35,39 +35,63 @@ class MessageTemplate::ProjectSettingChanged < MessageTemplate
|
|||
end
|
||||
# 项目简介更改
|
||||
if change_params[:description].present?
|
||||
if change_count > 1
|
||||
content.sub!('{ifdescription}', '<br/>')
|
||||
if change_params[:description][1].blank?
|
||||
if change_count > 1
|
||||
content.gsub!(/({ifdescription})(.*)({enddescription})/, '<br/>删除了项目简介')
|
||||
else
|
||||
content.gsub!(/({ifdescription})(.*)({enddescription})/, '删除了项目简介')
|
||||
end
|
||||
else
|
||||
content.sub!('{ifdescription}', '')
|
||||
if change_count > 1
|
||||
content.sub!('{ifdescription}', '<br/>')
|
||||
else
|
||||
content.sub!('{ifdescription}', '')
|
||||
end
|
||||
content.sub!('{enddescription}', '')
|
||||
content.gsub!('{description}', change_params[:description][1])
|
||||
end
|
||||
content.sub!('{enddescription}', '')
|
||||
content.gsub!('{description}', change_params[:description][1])
|
||||
else
|
||||
content.gsub!(/({ifdescription})(.*)({enddescription})/, '')
|
||||
end
|
||||
# 项目类别更改
|
||||
if change_params[:project_category_id].present?
|
||||
category = ProjectCategory.find_by_id(change_params[:project_category_id][1])
|
||||
if change_count > 1
|
||||
content.sub!('{ifcategory}', '<br/>')
|
||||
else
|
||||
content.sub!('{ifcategory}', '')
|
||||
if category.present?
|
||||
if change_count > 1
|
||||
content.sub!('{ifcategory}', '<br/>')
|
||||
else
|
||||
content.sub!('{ifcategory}', '')
|
||||
end
|
||||
content.sub!('{endcategory}', '')
|
||||
content.gsub!('{category}', category&.name)
|
||||
else
|
||||
if change_count > 1
|
||||
content.gsub!(/({ifcategory})(.*)({endcategory})/, '<br/>删除了项目类别')
|
||||
else
|
||||
content.gsub!(/({ifcategory})(.*)({endcategory})/, '删除了项目类别')
|
||||
end
|
||||
end
|
||||
content.sub!('{endcategory}', '')
|
||||
content.gsub!('{category}', category&.name)
|
||||
else
|
||||
content.gsub!(/({ifcategory})(.*)({endcategory})/, '')
|
||||
end
|
||||
# 项目语言更改
|
||||
if change_params[:project_language_id].present?
|
||||
language = ProjectLanguage.find_by_id(change_params[:project_language_id][1])
|
||||
if change_count > 1
|
||||
content.sub!('{iflanguage}', '<br/>')
|
||||
if language.present?
|
||||
if change_count > 1
|
||||
content.sub!('{iflanguage}', '<br/>')
|
||||
else
|
||||
content.sub!('{iflanguage}', '')
|
||||
end
|
||||
content.sub!('{endlanguage}', '')
|
||||
content.gsub!('{language}', language&.name)
|
||||
else
|
||||
content.sub!('{iflanguage}', '')
|
||||
if change_count > 1
|
||||
content.gsub!(/({iflanguage})(.*)({endlanguage})/, '<br/>删除了项目语言')
|
||||
else
|
||||
content.gsub!(/({iflanguage})(.*)({endlanguage})/, '删除了项目语言')
|
||||
end
|
||||
end
|
||||
content.sub!('{endlanguage}', '')
|
||||
content.gsub!('{language}', language&.name)
|
||||
else
|
||||
content.gsub!(/({iflanguage})(.*)({endlanguage})/, '')
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue