switch to httparty

This commit is contained in:
r888888888
2017-06-29 17:10:07 -07:00
parent ed7b80c016
commit eb6c5e3af5
16 changed files with 108 additions and 182 deletions

View File

@@ -28,18 +28,14 @@ class SavedSearch < ApplicationRecord
"queries" => queries
}.to_json
uri = URI.parse("#{Danbooru.config.listbooru_server}/v2/search")
uri = "#{Danbooru.config.listbooru_server}/v2/search"
body = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.is_a?(URI::HTTPS)) do |http|
resp = http.request_post(uri.request_uri, json)
if resp.is_a?(Net::HTTPSuccess)
resp.body
else
raise "HTTP error code: #{resp.code} #{resp.message}"
end
resp = HTTParty.post(uri, body: json)
if resp.success?
resp.body.to_s.scan(/\d+/).map(&:to_i)
else
raise "HTTP error code: #{resp.code} #{resp.message}"
end
body.to_s.scan(/\d+/).map(&:to_i)
end
end
end

View File

@@ -174,7 +174,7 @@ class User < ApplicationRecord
def update_remote_cache
if name_changed?
Danbooru.config.other_server_hosts.each do |server|
Net::HTTP.delete(URI.parse("http://#{server}/users/#{id}/cache"))
HTTParty.delete("http://#{server}/users/#{id}/cache")
end
end
rescue Exception