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
This commit is contained in:
BrokenEagle
2020-05-24 00:21:53 +00:00
parent 364343453c
commit b9b1177832
2 changed files with 5 additions and 2 deletions

View File

@@ -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")

View File

@@ -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