fix iqdbproxy
This commit is contained in:
@@ -53,7 +53,7 @@ class CurrentUser
|
||||
end
|
||||
|
||||
def self.root_url
|
||||
Thread.current[:current_root_url] || "http://#{Danbooru.config.hostname}/"
|
||||
Thread.current[:current_root_url] || "https://#{Danbooru.config.hostname}/"
|
||||
end
|
||||
|
||||
def self.root_url=(root_url)
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
class IqdbProxy
|
||||
def self.query(url)
|
||||
def self.query(image_url)
|
||||
raise NotImplementedError unless Danbooru.config.iqdbs_server.present?
|
||||
|
||||
url = URI.parse(Danbooru.config.iqdbs_server)
|
||||
url.path = "/similar"
|
||||
url.query = {url: url}.to_query
|
||||
url.query = {url: image_url}.to_query
|
||||
json = HTTParty.get(url.to_s, Danbooru.config.httparty_options).parsed_response
|
||||
decorate_posts(json)
|
||||
end
|
||||
|
||||
def self.decorate_posts(json)
|
||||
json.map do |x|
|
||||
x["post"] = Post.find(x["id"])
|
||||
x
|
||||
end
|
||||
begin
|
||||
x["post"] = Post.find(x["id"])
|
||||
x
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
nil
|
||||
end
|
||||
end.compact
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user