re621 / re621.Legacy

A comprehensive suite of tools that adds functionality and improves the browsing experience of e621.net
https://re621.bitwolfy.com
GNU General Public License v3.0
78 stars 14 forks source link

IQDB 403 error on upload page #360

Open nuenuewei opened 8 months ago

nuenuewei commented 8 months ago

Expected behaviour

The userscript attempts to check for duplicate images when the user selects a file for upload. I assume it's intended to warn the user if there's a hit.

Actual behaviour

https://i.imgur.com/qrfR6BY.png When file is selected, displays error message: "IQDB: Internal Error 403 Forbidden" with a retry link that doesn't resolve the issue.

I'm seeing this behaviour on

Browser + Userscript Manager e.g. Tampermonkey on Google Chrome v80. Tampermonkey on Waterfox G6.0.8(current)

Steps to reproduce

Just try to upload a picture in the upload form. I haven't tried it using URL uploading. https://e621.net/iqdb_queries works. Queries to IQDB from other extensions work. The image is correctly checked when hitting submit and blocked if a duplicate is found, so there's nothing going really wrong.

faucetlol commented 8 months ago

It's a very long-standing issue, I'm actually quite surprised this is the first report here on GitHub, or how nobody's ever took the time to fix it.

I took a look ages ago, I think the problem was something along the lines of re621 providing the IQDB endpoint with a local file path instead of uploading the file, which obviously won't work, resulting in an error.

It's worth noting that it functions perfectly fine when using URL uploading, which is generally recommended for many other reasons too.

bitWolfy commented 8 months ago

This may or not be an issue because I never sat down and tried to figure out how to pass on the local file over to IQDB. I wish I had more time to work on re621 these days. I do realize that this should be addressed at some point, but it's unlikely to happen soon.

hackerTiger21 commented 1 week ago

I wrote a fix, but there are some limitations due to the nature of querying with a file, since it requires using a POST request instead of a GET request.

I couldn't add a "Duplicates Found" link that linked to /iqdb_queries and passed the file like the URL search does, the dupes only show up on the upload page.

Likewise, I couldn't add any additional reverse image search links in risContainer with file uploads. Image query POST requests would all likely need an API key.

Finally, I couldn't figure out why the handleInput function doesn't fire on drag-and-drop. I tried adding the drop event to the listener alongside input and paste, but nothing happened on drag/drop.

Ultimately, those issues are minimal or beyond the scope of the weird 403 error, which has been resolved.

nuenuewei commented 1 week ago

Considering that I was only expecting, at most, for the check to be disabled when posting a local upload so the error wouldn't show, even a partially working or roundabout way to get an actual dupe check done would be above and beyond. Thanks for your hard work!