mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-02 19:30:48 +08:00
init project
This commit is contained in:
33
app/jobs/sync_trustie_job.rb
Normal file
33
app/jobs/sync_trustie_job.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
require 'uri'
|
||||
require 'net/http'
|
||||
|
||||
class SyncTrustieJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(type, count)
|
||||
Rails.logger.info("#######_________response__sync__start__#########")
|
||||
|
||||
token = EduSetting.get('trustie_api_token')
|
||||
api_host = EduSetting.get('trustie_api_url')
|
||||
|
||||
url = "#{api_host}/api/v1/homes/sync_count"
|
||||
sync_json = {
|
||||
"token": token,
|
||||
"type": type,
|
||||
"number": count
|
||||
}
|
||||
uri = URI.parse(url)
|
||||
# http = Net::HTTP.new(uri.hostname, uri.port)
|
||||
|
||||
if api_host
|
||||
http = Net::HTTP.new(uri.hostname, uri.port)
|
||||
|
||||
if api_host.include?("https://")
|
||||
http.use_ssl = true
|
||||
end
|
||||
|
||||
response = http.send_request('PUT', uri.path, sync_json.to_json, {'Content-Type' => 'application/json'})
|
||||
Rails.logger.info("#######_________response__sync__end_____#########{response.body}")
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user