diff --git a/app/logical/current_user.rb b/app/logical/current_user.rb index c18c91a59..d3631fa9c 100644 --- a/app/logical/current_user.rb +++ b/app/logical/current_user.rb @@ -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) diff --git a/app/logical/iqdb_proxy.rb b/app/logical/iqdb_proxy.rb index d5330f562..09660bd3b 100644 --- a/app/logical/iqdb_proxy.rb +++ b/app/logical/iqdb_proxy.rb @@ -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