Commit Graph

291 Commits

Author SHA1 Message Date
evazion
9a0a988572 tests: fix test breakage in Github CI.
Fix tests not working in Github. They were failing because the latest
version of Webpack needs a version of Node newer than the version in
shipped Ubuntu 20.04.

Also fix the Docker build failing because of the system timezone
database not being installed in Ubuntu 20.10.
2021-02-05 03:40:16 -06:00
evazion
896e5cb763 Add BetterErrors gem. 2021-01-30 14:19:37 -06:00
evazion
af84386d77 webpack: fix hot reloading not working.
Upgrade to webpacker-6.0.0.beta.4 to fix a bug where bin/webpack-dev-server
didn't respect the host/port config options in config/webpacker.yml,
which made it listen on the wrong port, breaking hot reloading.
2021-01-29 02:09:30 -06:00
evazion
2c06766c9e gems: workaround meta_request failure in Rails 6.1.
meta_request fails in Rails 6.1 with a `SystemStackError: stack level
too deep` error. Switch to a patched fork until the mainline gem is
fixed.

* hxxps://www.github.com/dejan/rails_panel/pull/177
* hxxps://www.github.com/dejan/rails_panel/issues/178
2021-01-24 19:26:25 -06:00
evazion
6ca007ee1f Fix #4670: Replace RequestStore with AS::CurrentAttributes.
This also requires replacing CurrentUser.name with CurrentUser.user.name
because the `name` method had a conflict with CurrentAttributes.
2021-01-16 12:43:20 -06:00
evazion
1b30b71a07 posts: refactor post previews to use ViewComponent.
Refactor the post preview html to use the ViewComponent framework. This
lets us encapsulate all the HTML, CSS, and helper methods for a UI
component in a single place.

See https://viewcomponent.org.
2021-01-14 21:17:57 -06:00
evazion
5fc99b9946 Upgrade to Rails 6.1.
* Swap out activerecord-hierarchical_query gem for some guy's patched
  version because the mainline version is incompatible with 6.1.
* Disable meta_request gem because it hangs puma on startup on 6.1.
2020-12-18 02:04:43 -06:00
evazion
2144f45fa4 users: add account upgrade integration tests.
* Test that the user upgrade process integrates with Stripe correctly.
* Replace a deprecated `card` param with `source` in `Stripe::Charge.create`.
* Rescue Stripe::StripeError instead of Stripe::CardError so that we
  handle failures outside of card failures, such as network errors.
2020-12-13 21:21:08 -06:00
evazion
62b69eb133 gems: upgrade http-cookie to fix Rails 6.1 bug.
Upgrade the http-cookie gem to a personal fork containing a bugfix for a
http-cookie bug that is triggered by Rails 6.1.

The bug is that HTTP::Cookie objects raise an exception if they're
compared against non-cookie objects. This bug gets triggered when
the Nijie source strategy calls `Rails.cache.fetch` to cache the
Nijie login cookie. `Rails.cache.fetch` ends up calling
ActiveSupport::Cache::Store::Entry#dup_value!, which compares the cookie
with `true`, which triggers the exception.

The http-cookie gem hasn't been updated for 4 years, so we're stuck
patching the library ourselves.
2020-12-13 04:10:48 -06:00
evazion
57dcd9ee1a Remove unused gems and yarn packages. 2020-06-30 23:44:03 -05:00
evazion
6020277608 Update simplecov gem. 2020-06-27 13:03:04 -05:00
evazion
09dff5b929 ci: track coverage with codecov.io instead of codeclimate.com.
Comparison:

* Codecov has a simpler integration and a better UI.
* Codeclimate tracks both linter warnings (Rubocop, ESLint) and code
  coverage, but its UI for code coverage is worse than Codecov's.
* Codeclimate doesn't support Simplecov 0.18 because Codeclimate doesn't
  support 0.18's new coverage format yet.
2020-06-27 13:01:35 -05:00
evazion
a4efeb2260 gems: drop Mechanize, HTTParty, and Sinatra gems. 2020-06-21 15:13:42 -05:00
evazion
f730951e7f gems: drop webmock. 2020-06-20 00:20:39 -05:00
evazion
440bbbb288 Update nokogiri gem.
Fix gem version conflicts described in 20abd8a5f. Nokogiri couldn't be
upgraded past 1.10.9 because 1.11.0 causes a build failure in Nokogumbo
2.0.2, but we couldn't stay on 1.10.9 either because it has a hard
requirement on Ruby <2.7 and we require Ruby >=2.7. This made `bundle
update` fail with a Gemfile conflict.

The fix is to disable libxml2 support when building Nokogumbo. Nokogumbo
wants to use the same version of libxml2 as Nokogiri, but Nokogiri
1.11.0 changed how it reports which version of libxml2 it's using, which
causes Nokogumbo's build to fail. Disabling libxml2 may reduce
performance of Nokogumbo ([1]).

While we're at it, we also make Nokogiri use the system version of
libxml2 instead of its own bundled version. Nokogiri really wants
us to use its own patched version of libxml2 instead of the system
version, but the patches it applies look relatively minor and don't seem
relevant to us ([2]). Using the system version reduces build time during CI.

This adds libxml2 and libxslt as OS-level dependencies of Danbooru. You
may need to do `sudo apt-get install libxml2-dev libxslt-dev` to install
these libraries after this commit.

[1]: https://github.com/rubys/nokogumbo#flavors-of-nokogumbo
[2]: https://github.com/sparklemotion/nokogiri/tree/master/patches/libxml2
2020-06-19 02:27:15 -05:00
evazion
025e09ff7f tests: upload test coverage reports to code climate.
Downgrade simplecov to 0.17 because 0.18 is incompatible with code
climate. Ref: github.com codeclimate/test-reporter/issues/413
2020-06-11 15:35:15 -05:00
evazion
e14a577ed9 tests: clean up test_helper.rb initialization. 2020-06-11 02:41:44 -05:00
evazion
15423e0b7b tests: add progress bar to test output.
Add minitest-reporters gem. Replace the default output of `bin/rails
test` with a progress bar. The default output just emits periods for
passed tests, which makes it hard to tell how long tests will take and
causes test runner output on Github to appear to hang. The web console
on Github is line buffered, but the default test runner doesn't normally
emit newlines (unless a test fails), so the output can hang for a long
time.
2020-06-10 17:52:33 -05:00
evazion
20abd8a5fd Fix build failure in nokogumbo.
Nokogumbo-2.0.2 fails to build when Nokogiri-1.11.0 is installed.
Nokogiri introduced some changes that are apparently incompatible with
Nokogumbo.

ref: https://nokogiri.org/CHANGELOG.html#versioninfo-and-the-output-of-nokogiri-v
2020-06-09 13:20:46 -05:00
evazion
9997db44d8 config: remove banned_ip_for_download? option.
* Remove `banned_ip_for_download?` config option. This isn't something that usually needs
  to be configured.
* Replace the `ipaddress` gem with `ipaddress_2`. The `ipaddress` gem has several methods
  we need (`link_local?`, etc) that are only available in master because the gem hasn't had
  an official release in several years. `ipaddress_2` is a fork that is more actively
  maintained.
2020-06-02 15:32:19 -05:00
evazion
91372a1ec5 gems: add Rubocop gem. 2020-05-06 01:22:26 -05:00
evazion
a6fac80e66 gems: drop ruby-imagespec gem.
* Use libvips instead of ruby-imagespec for reading dimensions of jpeg, png, and gif files.
* Copy the code for reading the dimensions of flash files from ruby-imagespec.

Fixes an incompatibility between ruby-imagespec and the rubocop gem that
prevented us from including rubocop in the Gemfile.
2020-05-06 01:21:35 -05:00
evazion
8001272170 gems: remove pry-inline and awesome_print gems.
The current release of pry-inline is broken. Neither of these gems were
that useful anyway.
2020-04-07 14:07:45 -05:00
evazion
e79910431f emails: validate that email addresses are deliverable.
Reject email addresses that known to be undeliverable during signup.
Some users signup with invalid email addresses, which causes the welcome
email (which contains the email confirmation link) to bounce. Too many
bounces hurt our ability to send mail.

We check that an email address is undeliverable by checking if the
domain has a mail server and if the server returns an invalid address
error when attempting to send mail. This isn't foolproof since some
servers don't return an error if the address doesn't exist. If the
checks fail we know the address is bad, but if the checks pass that
doesn't guarantee the address is good. However, this is still good
enough to filter out bad addresses for popular providers like Gmail and
Microsoft that do return nonexistent address errors.

The address existence check requires being able to connect to mail
servers over port 25. This may fail if your network blocks port 25,
which many home ISPs and hosting providers do by default.
2020-03-23 23:45:18 -05:00
evazion
1d16034144 pundit: add initial application policy. 2020-03-20 18:03:00 -05:00
evazion
a8e5412d9c implications: refactor calculation of implied tags.
Refactor to use a recursive CTE to calculate implied tags in SQL, rather
than storing them in a descendant_names field. This avoids the
complexity of keeping the stored field up to date. It's also more
flexible, since it allows us to find both descendant tags (tags that
imply a given tag) as well as ancestor tags (tags that are implied by a
given tag).
2020-02-22 22:37:36 -06:00
evazion
3c2a379d6f uploads: replace old upload limits with new upload limits. 2020-02-03 22:05:58 -06:00
evazion
da84e3a2f2 twitter: replace twitter gem with our own API client.
The twitter gem had several problems:

* It's been unmaintained for over a year.
* It pulled in a lot of dependencies, many of which were outdated. In
  particular, it locked the `http` gem to version 3.3, preventing us
  from upgrading to 4.2.
* It raised exceptions on normal error conditions, like for deleted
  tweets or suspended users, which we really don't want.
* We had to wrap it to provide caching.

Changes:

* Fixes #4226 (Exception when creating new artists entries for suspended
  Twitter accounts)
* Drop support for scraping images from summary cards. Summary cards
  are the previews you get when you link to a website in a tweet. These
  preview images aren't always the best image.
2019-12-13 17:27:03 -06:00
evazion
316690f393 storage manager: remove S3 backend.
Remove in favor of the rclone S3 backend.
2019-12-13 02:14:14 -06:00
evazion
92aca9ed2d storage manager: remove fog backend.
Remove in favor of rclone.
2019-12-13 01:45:43 -06:00
evazion
e4f4326982 storage manager: add backblaze b2 backend. 2019-12-10 02:04:32 -06:00
evazion
5cdccf4b93 Update gems. 2019-12-06 01:33:52 -06:00
evazion
bf6bb94702 Add new IP address search page.
Add a new IP address search page at /ip_addresses. Replaces the old
search page at /moderator/ip_addrs.

On user profile pages, show the user's last known IP to mods. Also add
search links for finding other IPs or accounts associated with the user.

IP address search uses a big UNION ALL statement to merge IP addresses
across various tables into a single view. This makes searching easier,
but is known to timeout in certain cases.

Fixes #4207 (the new IP search page supports searching by subnet).
2019-11-11 21:03:07 -06:00
evazion
69f005a89c gems: remove cityhash gem.
This gem uses a native extension that requires a C++ compiler to build.
Removing this gem removes the need to have a C++ toolchain to install Danbooru.
2019-11-09 14:42:30 -06:00
evazion
2821559221 gems: drop term-ansicolor gem. 2019-10-30 23:32:28 -05:00
evazion
f3f80ff4f8 gems: bump dtext version. 2019-10-11 18:45:55 -05:00
evazion
b2d0d2689b gems: remove unused google-api-client gem. 2019-09-27 21:14:38 -05:00
evazion
f2dccf8cf1 Remove mod-only bulk revert system (#4178).
The mass undo system added in #4178 is a replacement for the mod-only
bulk revert system.
2019-09-27 21:12:53 -05:00
evazion
02354e83fe tests: add autocomplete system tests. 2019-09-17 18:14:33 -05:00
evazion
648ba14021 gems: add rake to gemfile.
Fixes issue with newrelic failing to set up rake instrumentation:

    ERROR : Error while detecting rake_instrumentation:
    ERROR : NameError: uninitialized constant Rake::VERSION
2019-09-01 13:10:37 -05:00
evazion
6e7b882dda tests: skip ugoira tests if ffmpeg/mkvmerge not installed. 2019-09-01 13:10:37 -05:00
evazion
3f86a60457 Upgrade to Rails 6.0.0. 2019-08-27 18:13:30 -05:00
evazion
50df810e67 gems: drop foreman gem.
Foreman is unmaintained and locked to a really old version of thor,
which prevents upgrading to Rails 6.

The Procfile can still be used by manually installing Foreman with
`gem install foreman`. This is what Foreman's README recommends anyway.
2019-08-25 20:29:32 -05:00
evazion
dfe2b831a3 cache: replace memcache with redis.
Drop memcache. Use redis for all caching instead.
2019-08-22 23:15:34 -05:00
evazion
27a118dfc8 tests: drop timecop gem. 2019-08-18 11:24:41 -05:00
evazion
06b564cf76 Fix failure with did_you_mean in bundle install.
Deploying to production failed during `bundle install` because of an
incompatibility between did_you_mean-1.3.0 + ruby-2.6 + rubygems-3.0 +
bundler-2.0.

ref: `https://github.com/yuki24/did_you_mean/issues/117#issuecomment-482565387`
2019-08-15 01:23:10 -05:00
evazion
ca2e2c92b9 artist versions: fix uninitialized constant error.
Error appears intermittently depending on module load order.
2019-08-13 21:30:20 -05:00
evazion
601e58d5c5 Fix exception in legacy /post/index.xml endpoint.
Fixes intermittent `uninitialized constant LegacyController::Builder` exceptions.
2019-08-12 19:20:33 -05:00
evazion
266259de54 gems: add pry-rails, meta_request, rack-mini-profiler. 2019-08-09 00:05:50 -05:00
evazion
50fdb9fe92 Update gems. 2019-08-08 14:00:46 -05:00