fixed 创建仓库开通建木DevOps

This commit is contained in:
2022-12-15 11:38:03 +08:00
parent 309ba151be
commit 311852234f
6 changed files with 68 additions and 10 deletions

View File

@@ -0,0 +1,18 @@
class OpenProjectDevOpsJob < ApplicationJob
include ProjectsHelper
queue_as :message
def perform(project_id, user_id)
project = Project.find_by(id: project_id)
user = User.find_by(id: user_id)
url = "#{jianmu_devops_url}/#{jianmu_devops_code(project, user)}"
puts "jianmu_devops_url ===== #{url}"
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts "jianmu_devops_url ===== #{response.body}"
SendTemplateMessageJob.perform_later('ProjectOpenDevOps', user_id, project_id)
end
end

View File

@@ -217,6 +217,14 @@ class SendTemplateMessageJob < ApplicationJob
receivers = project&.all_managers.where.not(id: operator&.id)
receivers_string, content, notification_url = MessageTemplate::ProjectPraised.get_message_content(receivers, operator, project)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, project_id: project.id})
when 'ProjectOpenDevOps'
operator_id, project_id = args[0], args[1]
operator = User.find_by_id(operator_id)
project = Project.find_by_id(project_id)
return unless operator.present? && project.present?
receivers = User.where(id: operator.id)
receivers_string, content, notification_url = MessageTemplate::ProjectOpenDevOps.get_message_content(receivers, operator, project)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, project_id: project.id})
when 'ProjectPullRequest'
operator_id, pull_request_id = args[0], args[1]
operator = User.find_by_id(operator_id)