Commit Graph

8065 Commits

Author SHA1 Message Date
evazion
edc0c9df32 Fix exception in /pools/:id/order/edit. 2019-08-25 21:06:16 -05:00
evazion
86fa502c71 login page: remove 'sign in securely' link.
This link is unnecessary since Danbooru is now HTTPS-only.
2019-08-25 20:32:25 -05:00
evazion
11912e5cfd Update gems. 2019-08-25 20:29:32 -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
0df5c0fd2b Replace deprecated update_attributes with update.
https://rubyinrails.com/2019/04/09/rails-6-1-activerecord-deprecates-update-attributes-methods/

DEPRECATION WARNING: update_attributes! is deprecated and will be removed from Rails 6.1 (please, use update! instead)
2019-08-25 20:29:32 -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
8e39985d66 app controller: fix api responses on access denied errors.
Bug: A .json/.xml/.js request that resulted in an access denied error
returned a html response instead of a .json/.xml/.js response.
2019-08-25 20:29:32 -05:00
evazion
c7f8fbbec2 app controller: standardize access denied error handling.
Refactor to use `render_error_page` to handle User::PrivilegeError
exceptions. This way these exceptions are logged to New Relic.

Changes:

* Anonymous users aren't automatically redirected to the login page.
  Instead they're taken to the access denied page, which links to the
  login/signup pages.

* JSON/XML error responses return `message` instead of `reason`.
2019-08-24 23:10:22 -05:00
evazion
d4c43af1dd app controller: replace calls to access_denied with PrivilegeError.
Standardize controllers to raise User::PrivilegeError instead of calling
`access_denied` directly.
2019-08-24 23:10:22 -05:00
evazion
fda9843a55 app controller: standardize auth failure error handling. 2019-08-24 22:55:36 -05:00
evazion
bb7c993f4a app controller: clean up helpers.
* Move `show_moderation_notice?` out.
* Don't need to declare `helper :pagination` manually.
2019-08-24 22:55:36 -05:00
evazion
491cae6c60 app controller: standardize api limit error handling.
* Refactor api_check to use render_error_page so that api limit errors
  get logged to New Relic for analysis.

* Also standardize json error responses to return the error message in
  `message` instead of `reason`.
2019-08-24 22:55:36 -05:00
evazion
a6ed7ca936 app controller: move session[:started_at] init to SessionLoader. 2019-08-24 22:55:36 -05:00
evazion
1a964f7a10 app controller: move safe mode from app controller to SessionLoader. 2019-08-24 22:55:36 -05:00
evazion
f151285038 views: standardize page titles. 2019-08-24 22:55:35 -05:00
evazion
2d34e69737 api: disable csrf protection for api requests.
Fixes POST/PUT API requests failing with InvalidAuthenticityToken errors
due to missing CSRF tokens.

CSRF protection is only necessary for cookie-based authentication. For
non-cookie-based authentication we can safely disable it. That is, if
the user is already passing their login + api_key, then we don't need
to additionally verify the request with a CSRF token.

ref: 2e407fa476 (comments)
2019-08-24 22:55:35 -05:00
evazion
9c79f006f8 tests: move authentication tests out of post tests. 2019-08-24 22:55:35 -05:00
evazion
7c1552061b tests: fix authentication in controller tests.
Fix controller tests to login for real instead of faking it.
2019-08-24 22:55:35 -05:00
evazion
a9b0362fc7 Fix #4125: Detect forum and comment spam. 2019-08-23 22:41:47 -05:00
evazion
06ff249530 dmails: factor out spam detector service. 2019-08-23 22:38:03 -05:00
evazion
7ab701c19a dmails: clean up sender/recipient logic. 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
bb82011bb2 helpers: drop fast_link_to. 2019-08-22 23:33:58 -05:00
evazion
70e0d2fac2 tag change notices: use cache instead of using redis directly. 2019-08-22 23:28:49 -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
87c480e2ed tests: fix /users?name=<nonexistent> test. 2019-08-22 21:30:00 -05:00
evazion
e03f6b9bc0 tests: drop PostSets::Pool tests.
We no longer use this class for pool show pages. Only used by
inheritance by PostSets::FavoriteGroup.
2019-08-22 21:30:00 -05:00
evazion
6ba3d68792 dmails: fix feedback not being left when spammer is autobanned. 2019-08-22 21:29:58 -05:00
evazion
4f5d80bb60 forum post votes: fix conflicting scope name.
Fixes a conflict with `Enumerable#excluding` in Rails 6.

    Rename Array#without and Enumerable#without to Array#excluding and
    Enumerable#excluding. Old method names are retained as aliases.
2019-08-22 21:28:56 -05:00
evazion
84f4e076cc whenever: log cronjob output to log/whenever.log. 2019-08-22 17:28:53 -05:00
evazion
97cc873a3f maintenenace: fix db timeouts during vacuuming.
Setting the statement timeout at the beginning didn't work because
`PostPruner.new.prune!` clobbers the timeout (it calls `without_timeout`,
which doesn't restore the timeout properly if the timeout was zero).
2019-08-22 17:03:18 -05:00
evazion
fd639e3c81 capistrano: lower downtime window for delayed jobs. 2019-08-22 16:56:42 -05:00
evazion
831aa57cad posts/show: fix thresholded comments not being hidden on pageload. 2019-08-22 16:40:45 -05:00
evazion
d05ebfe116 dmails: fix bug preventing members from sending dmails.
Bug: sending dmails failed for members.

Cause: using lambdas with `rakismet_attrs` failed because unexpected
arguments are passed to the lambdas. Using procs works because the
arguments are ignored.

Also fix the tests to actually test akismet. We didn't catch this
because the tests mocked out the `spam?` call.
2019-08-22 00:42:49 -05:00
evazion
44653fb722 Fix errors on /artists/show_or_new, /wiki_pages/show_or_new pages.
Fix these pages to redirect to the new page instead of erroring out when
a name or title isn't given.
2019-08-22 00:09:50 -05:00
evazion
1292e73931 Fix errors on HEAD requests to various index pages.
Various search forms try to do `params[:search][:blah]`, which failed
for HEAD requests because we didn't normalize the `search` param.
2019-08-21 23:37:46 -05:00
evazion
ac259859f9 search: don't error out on source:*pixiv* searches. 2019-08-21 23:33:49 -05:00
evazion
d75d2266c9 users: fix error handling for /users?name=<does_not_exist>. 2019-08-21 23:32:34 -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
7cc31b97c9 pools/show: fix pagination to respect user's posts-per-page setting. 2019-08-21 14:31:58 -05:00
evazion
b283281e5e comments: minimize sql queries.
Certain parts of comment rendering triggered sql queries that we didn't
really need to do. Rework things to avoid this.

* Preload comment creators in order to display commenter names with link_to_user.

* Preload comment votes in order to display "undo vote" links. Only preload
  votes for members since anonymous users can't vote and don't have "undo
  vote" links.

* Rework various conditionals to do the filtering in Ruby so that we
  avoid issuing any extra queries in sql.

* Avoid issuing any queries at all when the post doesn't have any
  comments (when last_commented_at is blank).
2019-08-20 21:55:25 -05:00
evazion
2cf929ad6e comments: show "undo vote" link by default on voted comments (fix #4143). 2019-08-20 21:17:02 -05:00
evazion
6e708dec18 /artists/new: fix artist name input box sizing.
In production the name input is really big because the artist name
column in the production db is `text` rather than `character varying`,
and simpleform treats text columns as textbox inputs.
2019-08-19 19:49:31 -05:00
evazion
0b14146f6a posts: hotfix bug in /posts.json?tags=blah+order:random. 2019-08-19 18:51:33 -05:00
evazion
782d9f3d61 comment votes: fix error handling.
Return the comment itself and a standard error response on failure.
2019-08-19 17:22:36 -05:00
evazion
b8450671f2 /mod_actions: fix N+1 query. 2019-08-19 00:46:31 -05:00
evazion
d4a243c8d1 footer: abbreviate git hash. 2019-08-19 00:46:31 -05:00
evazion
13f4dee59f footer: only show keyboard shortcuts link on desktop. 2019-08-19 00:46:31 -05:00