|
|
|
@@ -7,6 +7,24 @@ class ChangeIssueStatusByMessageJob < ApplicationJob |
|
|
|
# Implement, Implements, Implemented, Implementing, implement, implements, implemented, implementing |
|
|
|
# 以上关键词后接 issue_id 例如:Closes #234 Closes #123, #245, #992 |
|
|
|
|
|
|
|
|
|
|
|
def get_pm_issue_data(user, org, pm_project_id, issue_id) |
|
|
|
url = URI("#{EduSetting.get("pms_server_url")}/api/pms/#{org.login}/pmsProjectIssues/#{issue_id}?pmProjectId=#{pm_project_id}") |
|
|
|
|
|
|
|
|
|
|
|
https = Net::HTTP.new(url.host, url.port) |
|
|
|
https.use_ssl = true |
|
|
|
request = Net::HTTP::Get.new(url) |
|
|
|
request["Cookie"] = "autologin_trustie=#{Token.get_or_create_permanent_login_token(user, 'autologin')&.value}" |
|
|
|
response = https.request(request) |
|
|
|
|
|
|
|
puts response.read_body |
|
|
|
return JSON.parse(response.read_body)['code'].to_i == 200 |
|
|
|
rescue |
|
|
|
return false |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def perform(commitsha, project, user, tag_issue_id_content, status_id=1) |
|
|
|
Rails.logger.info "需要操作的issue_id内容为 #{tag_issue_id_content}" |
|
|
|
tag_issue_id_content = tag_issue_id_content.gsub(/\s+/, '') |
|
|
|
@@ -14,8 +32,9 @@ class ChangeIssueStatusByMessageJob < ApplicationJob |
|
|
|
issue_id = tag_issue.gsub('#', '') |
|
|
|
issue = project.issues.issue_issue.where(project_issues_index: issue_id).where.not(id: issue_id).take || Issue.issue_issue.find_by_id(issue_id) |
|
|
|
next unless issue.present? # issue不存在 跳过 |
|
|
|
next if issue.project.present? && !user.admin? && !issue.project.member?(user) # issue归属项目,用户没有修改issue的权限,跳过 |
|
|
|
next if issue.pm_project_id.present? && project.owner.is_a?(Organization) && !project.owner.is_member?(user.id) # issue是组织下工作项,不具备组织的访问权限,跳过 |
|
|
|
next if issue.project.present? && !issue.project.member?(user) # issue归属项目,用户没有修改issue的权限,跳过 |
|
|
|
next if issue.pm_project_id.present? && !get_pm_issue_data(user, project.owner, issue.pm_project_id, issue.id) # issue是组织下工作项,不具备组织的访问权限,跳过 |
|
|
|
|
|
|
|
issue_project = issue.project || Project.new(id: 0, user_id: 0, name: 'pm_mm', identifier: 'pm_mm', is_public:true) |
|
|
|
if issue.pm_project_id.present? |
|
|
|
Api::Pm::Issues::UpdateService.call(issue_project, issue, {status_id: status_id}, user, "Project##{project.id}@#{commitsha}") |
|
|
|
|