Commit Graph

952 Commits

Author SHA1 Message Date
evazion
d3165f78aa comment votes: add index page. 2019-10-28 14:12:40 -05:00
evazion
f4376fc7a3 post votes: add index page. 2019-10-28 03:21:18 -05:00
evazion
dfbf4f3f0a Remove single alias/implication requests.
* Remove the single alias and implication request forms. From now
  on, bulk update requests are the only way to request aliases or
  implications.

* Remove the forum topic ID field from the bulk update request form.
  Instead, to attach a BUR to an existing topic you go to the topic then
  you click "Request alias/implication" at the top of the page.

* Update the bulk update request form to give better examples for the
  script format and to explain the difference between aliases and
  implications.
2019-10-28 01:36:28 -05:00
evazion
0e159960a2 forum post votes: add index page. 2019-10-28 01:06:23 -05:00
evazion
3a544ba5e0 Fix tag ordering in humanized_essential_tag_string.
* Pick the largest character or copyright tags by post count. Previously
  we picked the tags with the longest names, which was nonsensical.

* Remove tag cateogory logic from config file. We can't avoid hardcoding
  some knowledge about tag categories here, so there's no point in trying.

This affects tab titles on post show pages as well as filenames in
downloaded images.
2019-10-26 02:36:55 -05:00
evazion
812cabfc07 dtext links: add basic index page. 2019-10-23 21:36:48 -05:00
evazion
2c6567b5d2 Remove uses of the read replica database.
https://danbooru.donmai.us/forum_topics/9127?page=283#forum_post_160508

There was a recent outage that was caused by the read replica
(yukinoshita.donmai.us) being temporarily unavailable. The pg driver in
rails got hardstuck trying to connect to the replica, which brought down
the whole site. The app servers stopped responding and could only be
brought down with SIGKILL. Even try to boot the rails console didn't
work.

We only really used this to calculate tag counts inside Post.fast_count,
which wasn't really beneficial since the read replica is slower than the
main database.
2019-10-22 12:15:46 -05:00
evazion
ae521e600e iqdb: proxy iqdb searches through danbooru.
Previously the search form on the /iqdb_queries page submitted directly
to the iqdb service (karasuma.donmai.us), which redirected back to
Danbooru with the search results.

This was different than API requests, which submitted to
/iqdb_queries.json which proxied the call to iqdb through Danbooru.
Because of this, searches on the /iqdb_queries page had different
behavior than API requests. Things like filesize limits and referrer
spoofing were handled differently.

Now searches on the /iqdb_queries page submit directly to Danbooru. This
is simpler and it means that API requests and HTML requests have the
same behavior.
2019-10-14 21:16:04 -05:00
evazion
3e37869768 rails: disable asset pipeline.
Disable the assets pipeline (Sprockets). Sprockets errors out now after
upgrading to Sprockets 4 because of missing config files. We don't use
it any more after switching to Webpack, so we can disable it entirely.

Also disable a few more Rails features that we don't use (ActiveStorage,
ActionCable, ActionMailbox, ActionText).
2019-10-14 13:50:31 -05:00
evazion
93dd952949 pagination: refactor to avoid counting pages in API.
Previously the page-based (numbered) paginator would always count the
total_pages, even in API calls when it wasn't needed. This could be very
slow in some cases. Refactor so that total_pages isn't calculated unless
it's called.

While we're at it, refactor to condense all the sequential vs. numbered
pagination logic into one module. This incidentally fixes a couple more
bugs:

* "page=b0" returned all pages rather than nothing.
* Bad parameters like "page=blaha123" and "page=a123blah" were accepted.
2019-10-07 22:01:37 -05:00
evazion
e3b49a2a6d unicorn: bump worker processes (16 -> 20). 2019-09-30 01:00:28 -05:00
evazion
a39b67b901 Remove mod-only user revert system (#4178).
The mass undo system from #4178 replaces this system.

Followup to f2dccf8cf.
2019-09-27 21:48:49 -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
3b63f94968 user name changes: remove unused reason, status fields.
Remove all infrastructure around approving or rejecting user name
changes. Name changes haven't been moderated for several years.

* Remove status, approver_id, change_reason, and rejection_reason fields.
* Remove approve and reject controller actions.
2019-09-25 21:43:01 -05:00
evazion
bc34fb16a4 tags: automatically fix incorrect tag counts during maintenance.
* Automatically fix all tags with incorrect counts during daily
  maintenance (previously only tags with negative counts were fixed).
* Log fixed tags to NewRelic.
* Remove the ability to manually fix tag counts with the "Fix" button on
  the /tags listing. This is no longer necessary now that tags are
  fixed automatically.
2019-09-25 17:57:11 -05:00
evazion
c325bfa199 css: factor out colors from main css (#4158). 2019-09-17 00:28:41 -05:00
evazion
059e061b15 tests: fixup comment vote, post controller tests.
Use git clean to delete stale files from an earlier checkout. These
files interfered with various things (specifically, a comment vote test
failed because there was an old comment_votes/create.json.erb template
hanging around that changed the behavior of the POST /comment_votes endpoint).
2019-09-09 15:06:24 -05:00
evazion
efca48ee96 Set SameSite=Lax on session cookies.
https://web.dev/samesite-cookies-explained
2019-09-09 11:51:01 -05:00
evazion
312606bf98 Fix #4137: Share cookies across subdomains 2019-09-09 11:51:01 -05:00
evazion
763ac1a7e0 pools: stop maintaining pool category pseudotags in pool strings (#4160)
Stop maintaining pool category pseudo tags (pool:series, pool:collection)
in pool strings. They're no longer used and the changes to the
`Post#pools` method in dc4d2e54b caused issues with this.

Also allow Members to change the category of large pools again. This was
only restricted because maintaining these pseudotags forced us to update
every post in the pool whenever a pool's category was changed.
2019-09-08 23:28:02 -05:00
evazion
d0f060d8eb api: refactor api attribute declarations.
Replace the `method_attributes` and `hidden_attributes` methods with
`api_attributes`. `api_attributes` can be used as a class macro:

    # include only the given attributes.
    api_attributes :id, :created_at, :creator_name, ...

    # include all default attributes plus the `creator_name` method.
    api_attributes including: [:creator_name]

or as an instance method:

    def api_attributes
       [:id, :created_at, :creator_name, ...]
    end

By default, all attributes are included except for IP addresses and
tsvector columns.
2019-09-08 23:28:02 -05:00
evazion
3f7e05316d api: refactor default options for xml responses.
In xml responses, if the result is an empty array we want the response
to look like this:

   <posts type="array"/>

not like this (the default):

   <nil-classes type="array"/>

This refactors controllers so that this is done automatically instead of
having to manually call `@things.to_xml(root: "things")` everywhere. We
do this by overriding the behavior of `respond_with` in `ApplicationResponder`
to set the `root` option by default in xml responses.
2019-09-08 15:32:31 -05:00
evazion
f673552743 users: add /settings page.
Add /settings page and link to it instead of /users/:id/edit.
2019-09-01 15:00:27 -05:00
evazion
ff92b32f02 users: add /profile page (fix #4151).
* Add /profile, /profile.json endpoints.
* Make "My Account" link to /profile.
* Add 'User ID' field to profile page.
2019-09-01 15:00:23 -05:00
evazion
1bb1b147ea Fix autoloading deprecation warning in delayed job initializer.
DEPRECATION WARNING: Initialization autoloaded the constants
    Danbooru::Paginator and Danbooru::Paginator::ActiveRecordExtension.

    Being able to do this is deprecated. Autoloading during
    initialization is going to be an error condition in future versions
    of Rails.

    Reloading does not reboot the application, and therefore code
    executed during initialization does not run again. So, if you reload
    Danbooru::Paginator, for example, the expected changes won't be
    reflected in that stale Module object.

    `config.autoloader` is set to `classic`. These autoloaded constants
    would have been unloaded if `config.autoloader` had been set to
    `:zeitwerk`.

    Please, check the "Autoloading and Reloading Constants" guide for
    solutions.
2019-09-01 13:10:37 -05:00
evazion
65e53b86b3 Drop support for /cache/tag.json.
Drop support for https://danbooru.donmai.us/cache/tags.json. This was a
nightly dump of the tags table that was originally added in #1012. It
was never documented and never really used except for by the DanbooruUp
extension.
2019-08-29 00:52:23 -05:00
evazion
eba6440b8b Fix #4144: Deviantart Eclipse update broke strategy. 2019-08-28 23:40:29 -05:00
evazion
0cf9f845d0 newrelic: fix tracking of api auth failure errors.
Fixes user params not being recorded on SessionLoader::AuthenticationFailed errors.
2019-08-27 21:19:56 -05:00
evazion
2c3ecf7ea4 Kill utf8=✓ param. 2019-08-27 18:13:30 -05:00
evazion
3f86a60457 Upgrade to Rails 6.0.0. 2019-08-27 18:13:30 -05:00
evazion
62875eabb2 /posts.atom: fix banned posts being visible to Members.
Bug: /posts.atom only hid loli/shota, not banned posts and not unsafe
posts when safe mode was on.
2019-08-25 20:29:32 -05:00
evazion
0101b5f5f4 danbooru default config: remove unused config settings. 2019-08-25 20:29:32 -05:00
evazion
1a964f7a10 app controller: move safe mode from app controller to SessionLoader. 2019-08-24 22:55:36 -05:00
evazion
06ff249530 dmails: factor out spam detector service. 2019-08-23 22:38:03 -05:00
evazion
0b78485227 dotenv: load .env.local before initializers. 2019-08-23 22:30:23 -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
2e407fa476 rails: update defaults from 5.1 to 5.2.
protect_from_forgery removed from because it's now on by default.

ref: https://edgeguides.rubyonrails.org/configuring.html
2019-08-22 22:09:05 -05:00
evazion
84f4e076cc whenever: log cronjob output to log/whenever.log. 2019-08-22 17:28:53 -05:00
evazion
804ccd4fcc capistrano: fix cronjobs not updating.
Bug: capistrano didn't update the crontab during deployment. As a result
the crontab still referenced an old deployment. Eventually that
deployment was deleted and cronjobs started silently failing.

Broken in 223e5f1e8. Turns out that `whenever` defaults to running on
servers with the `db` role. Removing kagamihara from the db role meant
that whenever was no longer configured to run anywhere.
2019-08-21 18:02:55 -05:00
evazion
82fbb19e0f users: drop unused code. 2019-08-18 11:24:42 -05:00
evazion
822dce20ed jobs: add base ApplicationJob. 2019-08-16 20:49:34 -05:00
evazion
2b236a7111 unicorn: bump worker count (12 -> 16). 2019-08-15 00:36:25 -05:00
evazion
13dbdd5cd9 unicorn: clear environment variables during hot restarts.
Fixes an issue with zero downtime deployments (#4123). Hot restarting
didn't clear out BUNDLER_GEMFILE, which mean that new workers still used
the old Gemfile from previous deployments. This led to mysterious errors
with autoloading libraries (#4138).
2019-08-15 00:36:25 -05:00
evazion
4833b8a63c Fix the circleci build. 2019-08-14 16:42:37 -05:00
evazion
e29e5fe984 Fix #4131: Upgrade to Ruby 2.6.
Upgrade procedure:

    $ echo 2.6.3 > .ruby-version

    # upgrade ruby-build to know about the latest ruby versions.
    # see also: github.com/rkh/rbenv-update
    $ cd ~/.rbenv/plugins/ruby-build && git pull

    # install the version of ruby specified in .ruby-version.
    # see also: github.com/capistrano/rbenv/issues/83
    $ rbenv install --skip-existing

    # update the shell to use the latest version of ruby by default.
    $ rbenv global 2.6.3

    # update rubygems and bundler
    $ gem update --system

    # update the lockfile to use the latest version of bundler
    $ bundle update --bundler
2019-08-14 12:25:50 -05:00
evazion
90fa67d4c1 Remove unused terms of service banner.
No longer used, inadvertently hidden in a6233f297e.
2019-08-14 01:46:44 -05:00
evazion
d0428da120 sessions: remove nonexistent GET /session route. 2019-08-14 01:46:43 -05:00
evazion
9b57631046 capistrano: fix newrelic deployment tagging.
Override the appname in config/newrelic.yml so that we don't
accidentally tag deployments under the wrong app.
2019-08-12 19:20:33 -05:00
evazion
f268293105 delayed jobs: log to stdout.
Log to stdout because we now run workers under systemd and we want
errors to go to the journal, not to log/production.log.
2019-08-12 13:38:45 -05:00
evazion
18a216c67a Fix #4130: Remove tag alias corrections. 2019-08-10 22:46:49 -05:00