class OpenProjectDevOpsJob < ApplicationJob
  include ProjectsHelper

  queue_as :message

  def perform(project_id, user_id)
    project = Project.find_by(id: project_id)
    return if project.blank?
    return if EduSetting.get("jianmu_devops_url").blank?
    user = User.find_by(id: user_id)
    code = jianmu_devops_code(project, user)
    uri = URI.parse("#{jianmu_devops_url}/activate?code=#{URI.encode_www_form_component(code)}")
    response = Net::HTTP.get_response(uri)
    puts "jianmu_devops_url response.code ===== #{response.code}"
    SendTemplateMessageJob.perform_later('ProjectOpenDevOps', user_id, project_id)
  end

end