From b9b11778326c7d0fe7fd05a1ee7409f2da1a8dda Mon Sep 17 00:00:00 2001 From: BrokenEagle Date: Sun, 24 May 2020 00:21:53 +0000 Subject: [PATCH] Adds suport for using the image_url parameter with IQDB This was only halfways supported, as the download module does not have an image_url function. So for this, it just uses the url function, which is just the original URL passed into the download function. Additionally, it adds support to grab the largest available image, which it does by using the file_url function of the downloads module. - Fixes image_url parameter - Adds file_url parameter --- app/controllers/iqdb_queries_controller.rb | 2 +- app/logical/iqdb_proxy.rb | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/iqdb_queries_controller.rb b/app/controllers/iqdb_queries_controller.rb index 1bf36bc86..21a063838 100644 --- a/app/controllers/iqdb_queries_controller.rb +++ b/app/controllers/iqdb_queries_controller.rb @@ -3,7 +3,7 @@ class IqdbQueriesController < ApplicationController def show # XXX allow bare search params for backwards compatibility. - search_params.merge!(params.slice(:url, :image_url, :post_id, :limit, :similarity, :high_similarity).permit!) + search_params.merge!(params.slice(:url, :image_url, :file_url, :post_id, :limit, :similarity, :high_similarity).permit!) @high_similarity_matches, @low_similarity_matches, @matches = IqdbProxy.search(search_params) respond_with(@matches, template: "iqdb_queries/show") diff --git a/app/logical/iqdb_proxy.rb b/app/logical/iqdb_proxy.rb index b77ef02fe..a812596ff 100644 --- a/app/logical/iqdb_proxy.rb +++ b/app/logical/iqdb_proxy.rb @@ -25,7 +25,10 @@ class IqdbProxy file = download(params[:url], :preview_url) results = query(file: file, limit: limit) elsif params[:image_url].present? - file = download(params[:image_url], :image_url) + file = download(params[:image_url], :url) + results = query(file: file, limit: limit) + elsif params[:file_url].present? + file = download(params[:file_url], :file_url) results = query(file: file, limit: limit) elsif params[:post_id].present? url = Post.find(params[:post_id]).preview_file_url