Commit Graph

9595 Commits

Author SHA1 Message Date
evazion
44f826d8fa nicoseiga: optimize image_url method.
The image_url method makes a request to `https://seiga.nicovideo.jp/images/source/:image_id`
to see where this URL redirects to. Before we did a GET request, which caused it to download
the full image. This could fail with a timeout error if the download took too long. We also
cached the request, which caused the full image to be cached, even though we only need the
headers. Change it to a HEAD request so we don't have to download the entire image just to
check the URL.
2020-06-24 22:54:04 -05:00
evazion
5af50b7fcd danbooru::http: factor out Cloudflare Polish bypassing.
* Factor out the Cloudflare Polish bypass code to a standalone feature.

* Add `http_downloader` method to the base source strategy. This is a
  HTTP client that should be used for downloading images or making
  requests to images. This client ensures that referrer spoofing and
  Cloudflare bypassing are performed.

This fixes a bug with the upload page reporting the polished filesize
instead of the original filesize when uploading ArtStation images.
2020-06-24 22:54:04 -05:00
evazion
d3bb5c67ee danbooru::http: factor out referrer spoofing.
Factor out referrer spoofing so that it can be used outside of downloading
files. We also need to spoof the referrer when determining the remote
filesize of images on the uploads page.
2020-06-24 21:46:59 -05:00
evazion
f84ceb3938 image proxy: raise image download timeout.
Possible fix for large Pixiv previews on the upload page sometimes
returning HTTP 500 errors.
2020-06-24 19:31:47 -05:00
evazion
b09350c0dc tests: add more Tag.search tests.
Improve tag model test coverage.
2020-06-24 18:39:55 -05:00
evazion
4074cc99f9 uploads: fix incorrect remote sizes on pixiv uploads.
Bug: the uploads page showed a remote size of 146 bytes for Pixiv uploads.

Cause: we didn't spoof the Referer header when making the HEAD request
for the image, causing Pixiv to return a 403 error.

Also fix the case where the Content-Length header is absent.
2020-06-24 03:02:45 -05:00
evazion
8eac82a971 pixiv: fix regression with new user profile urls.
* Update tests to use new Pixiv profile urls.
* Fix issue with artist finder not working when given direct image or
  html page urls.
2020-06-24 02:41:11 -05:00
evazion
1d369f4574 ci: notify when a PR has a merge conflict.
Adds a "merge conflict" label and posts a comment when a PR has a merge
conflict. See https://github.com/Marr11317/ConflictAdviser#limitations.
2020-06-24 02:01:41 -05:00
evazion
85f58bf2f6 newgrounds: fix style nitpicks. 2020-06-24 00:25:45 -05:00
evazion
42c06b0f1e Merge pull request #4516 from nonamethanks/add_newgrounds_support
Add NewGrounds support
2020-06-24 00:20:16 -05:00
evazion
dfc7812abe Merge pull request #4518 from BrokenEagle/fix-pixiv-profile-url
Fix pixiv profile url
2020-06-24 00:07:18 -05:00
evazion
185693b99b Merge branch 'master' into fix-pixiv-profile-url 2020-06-24 00:06:55 -05:00
evazion
8ef2b7772d Merge pull request #4530 from BrokenEagle/parent-child-status-search
Add ability to search on status of parent/child
2020-06-23 23:53:57 -05:00
evazion
bb765f55d5 Eliminate misc dead code. 2020-06-23 23:37:56 -05:00
evazion
5f3c41416e tests: add more wiki page controller search tests. 2020-06-23 23:36:16 -05:00
evazion
2b969646bc tests: add respond_to_search test helper.
Add a `respond_to_search` test helper for concisely testing that a
controller's index action correctly responds to a search. Usage:

    # Tests that `/tags.json?search[name]=touhou` returns the `touhou` tag.

    setup { @touhou = create(:tag, name: "touhou") }
    should respond_to_search(name: "touhou").with { @touhou }
2020-06-23 23:35:48 -05:00
evazion
d71f3cbac1 Merge pull request #4531 from BrokenEagle/wiki-linked-to
Add option to search for wikis that don't link to a specific wiki
2020-06-23 23:21:16 -05:00
evazion
83a8468ee9 tests: remove unnecessary rescueing of Net::OpenTimeout errors.
These exceptions are no longer thrown now that we've switched from
HTTParty to http.rb. Swallowing unexpected exceptions during testing was
a bad practice anyway.
2020-06-23 03:12:44 -05:00
evazion
be4bdfc136 artists: add test for hiding deleted wikis on artist pages (#4526). 2020-06-23 03:01:32 -05:00
evazion
d1e0542eb5 Merge pull request #4534 from BrokenEagle/fix-4533
Fix the tag matches option
2020-06-23 03:00:32 -05:00
evazion
05fbbc69e6 Merge pull request #4529 from BrokenEagle/deleted-artist-wiki
Don't display artist wiki when it is deleted
2020-06-23 02:51:53 -05:00
evazion
0276792b35 BURs: add test for users voting on their own BURs (#4527) 2020-06-23 02:43:12 -05:00
evazion
da9c145c64 Merge pull request #4527 from BrokenEagle/forum-post-voting
Prevent creators from voting on their own BURs
2020-06-23 02:42:46 -05:00
evazion
8a21c9a8db Merge pull request #4523 from nonamethanks/revert_pixiv_tools
Revert "Pixiv: don't blacklist digital tools"
2020-06-23 02:39:18 -05:00
evazion
617211f405 Merge pull request #4521 from nonamethanks/zerochan_png
Zerochan: Normalize png links
2020-06-23 02:38:39 -05:00
evazion
73506bac33 twitter: add tests for uploading profile banners (#4520). 2020-06-23 02:37:21 -05:00
evazion
f2ae9eeae0 Merge pull request #4528 from nonamethanks/fix_4520
Twitter: don't get api without a status id
2020-06-23 02:36:32 -05:00
BrokenEagle
1a87935764 Fix the tag matches option
The split function was mistakenly used instead of the match function.
2020-06-23 06:58:03 +00:00
evazion
5dbe08372b nicoseiga: remove accept_fetish_warning.
This should have been a cookie, but it doesn't matter because the
strategy still works without it.
2020-06-23 00:49:38 -05:00
BrokenEagle
50740e302f Add option to search for wikis that don't link to a specific wiki
Also add inputs on the search page for both the linked_to and the
not_linked_to search parameters. Additionally, normalize the title
first since autocomplete adds trailing spaces. The search query was
also simplified a bit by taking advantage of Rails associations.
2020-06-23 05:31:43 +00:00
evazion
6ea2c934fd tests: temp skip failing danbooru::http redirect tests.
Skip for now until https://github.com/postmanlabs/httpbin/issues/617 is fixed.
2020-06-22 22:54:41 -05:00
evazion
7f5e87568a danbooru::http: raise exception on failed downloads.
Restore behavior from a6994cd4d, it breaks tests when they try to the
response body from a fake 599 response.
2020-06-22 22:51:36 -05:00
evazion
31802fb666 nijie: fix parallel test failures.
Nijie tests fail often under parallel testing. This is because every
test needs to login to Nijie first, but Nijie rate-limits the login
endpoint, so eventually we hit the limit and tests start failing.

This is made worse by a thundering herd problem. Eight test processes
try to login to Nijie at the same time, but only one succeeds, so the
rest sleep and try again, but they all wakeup and try again at the same
time, hitting the rate limits again.

The workaround is to set the retry limit ridiculously high, higher than
we would ideally like in production. Another workaround would be to
serialize the Nijie tests in the test suite. This can be done with
lockfiles and flock(2). This helps, but we can still hit the rate limit
even under serialized execution.
2020-06-22 22:21:17 -05:00
evazion
a6994cd4d7 media file: fix exception on empty files.
This may happen if a user uploads from a source that returns an error
HTTP response with no data.
2020-06-22 18:49:36 -05:00
evazion
8c6759bbd7 nicoseiga: fix login endpoint.
* Update the login endpoint. The old endpoint returns 404 now.

  POST https://account.nicovideo.jp/api/v1/login ->
  POST https://account.nicovideo.jp/login/redirector?site=seiga

* Let Danbooru::Http cache the login request instead of caching it manually.

* Let Danbooru::Http automatically follow redirects instead of dealing
  with the Location header manually.
2020-06-22 18:46:47 -05:00
evazion
95fee75d9a nicoseiga: fix uploads not working for certain direct image urls.
Fix Nicoseiga strategy to work with certain direct image urls that we
can't otherwise extract any information from.

Examples:

* https://dic.nicovideo.jp/oekaki/52833.png
2020-06-22 16:53:50 -05:00
evazion
db3407caa3 uploads: fix uploading from source not working.
ref: 26ad844bbe (r40077579).
2020-06-22 15:32:48 -05:00
evazion
b904c01d69 config: remove unused config files. 2020-06-21 19:01:12 -05:00
evazion
209350de5b scripts: remove unused danbooru-specific config.
Danbooru-specific configuration now lives in https://github.com/danbooru/danbooru-ansible.
2020-06-21 18:56:42 -05:00
evazion
504edff14b Update ruby gems and yarn packages. 2020-06-21 18:49:08 -05:00
evazion
bd25be95f5 danbooru::http: factor out cache feature.
Fixes a bug with cookies stored by the `session` feature not being sent
with cached requests.
2020-06-21 18:28:37 -05:00
evazion
f85eef9bcd nijie: fix bug with retries returning cached responses.
Bug: if a Nijie login failed with a 429 Too Many Requests error, the
error would get cached, so when we retried the request, we would just
get our own cached response back every time. The 429 error would
eventually be passed up to the Nijie strategy, which caused random
methods to fail because they couldn't get the html page.

Fix: add the `retriable` feature *after* the `cache` feature so that
retries don't go through the cache. This is a hack. We want retries to
go at the bottom of the stack, below caching, but we can't enforce this
ordering.
2020-06-21 18:13:21 -05:00
BrokenEagle
4acd89838b Add ability to search on status of parent/child 2020-06-21 22:39:21 +00:00
evazion
f020070b7d Add .editorconfig. 2020-06-21 15:15:47 -05:00
evazion
a4efeb2260 gems: drop Mechanize, HTTParty, and Sinatra gems. 2020-06-21 15:13:42 -05:00
evazion
5c7843bd3d scripts: refactor mocked services.
Replace the mocked services in scripts/mocked_services with Rails-level
mocked services.

The scripts in scripts/mocked_services were a set of stub Sinatra
servers used to mock the Reportbooru, Recommender, and IQDBs services
during development. They return fake data so you can test pages that use
these services.

Implementing these services in Rails makes it easier to run them. It
also lets us drop a dependency on Sinatra and drop a use of HTTParty.

To use these services, set the following configuration in danbooru_local_config.rb
or .env.local:

* reportbooru_server: http://localhost:3000/mock/reportbooru
* recommender_server: http://localhost:3000/mock/recommender
* iqdbs_server: http://localhost:3000/mock/iqdb

where `http://localhost:300` is the url for your local Danbooru server
(may need to be changed depending on your configuration).
2020-06-21 15:11:56 -05:00
evazion
29a5f7dfc8 image proxy: replace HTTParty with Danbooru::Http. 2020-06-21 15:11:56 -05:00
evazion
7e471fe223 sources: replace HTTParty with Danbooru::Http in http_exists?. 2020-06-21 15:11:56 -05:00
evazion
3ad8c708c5 pixiv: replace HTTParty with Danbooru::Http. 2020-06-21 15:11:56 -05:00
evazion
5604ab0079 pixiv: remove fanbox support.
This is broken and it needs to be rewritten as a separate source
strategy anyway.
2020-06-21 11:59:51 -05:00