Commit Graph
100 Commits
Author SHA1 Message Date
evazion 2d2efbddfe /iqdb_queries: add api test. 2017-04-05 18:48:57 -05:00
evazion 423dd0b848 /iqdb_queries: include full data for each post in api response. 2017-04-05 18:01:16 -05:00
evazion e15f955677 /iqdb_queries: support json/xml api responses. 2017-04-05 18:01:16 -05:00
evazion c402e15cca /iqdb_queries: support both GET and POST; add GET /posts/1/similar. 2017-04-05 18:01:16 -05:00
evazion 0974ef8bd4 iqdbs: raise exception if not configured. 2017-04-05 01:17:04 -05:00
evazion d66d19f328 big query: raise exception if not configured. 2017-04-05 01:17:04 -05:00
evazion f57561118c reportbooru: raise exception if not configured. 2017-04-05 01:17:04 -05:00
evazion 08867fa84d listbooru: raise exception if not configured. 2017-04-05 01:17:04 -05:00
evazion 086b520dcc archives: raise exception if not configured. 2017-04-05 01:17:03 -05:00
evazion 3f35a9ab64 Handle failure gracefully for unconfigured services. 2017-04-05 01:17:03 -05:00
evazion c03aa79ece Post#give_favorites_to_parent: wrap in transaction.
Ensure that if anything fails then the entire favorites move will be
rolled back.
2017-04-04 20:44:05 -05:00
evazion 40feeb2411 Post#give_favorites_to_parent: fix exception (fixup 77793759)
Forgot the `belong_to :user` association in 77793759.
2017-04-04 20:42:31 -05:00
evazion 777937591e Post#give_favorites_to_parent: move hidden favs. 2017-04-03 22:36:20 -05:00
evazion 5db39f308a tests: fix post approval tests. 2017-04-03 17:18:32 -05:00
evazion 7c8135609b post_approval_test.rb: tabs to spaces. 2017-04-03 17:18:32 -05:00
evazion e6328b8d30 post_approval_test.rb: move to test/unit. 2017-04-03 17:18:32 -05:00
evazion 70a7f77a48 Post#approve!: signal errors with invalid object instead of exception. 2017-04-03 17:18:32 -05:00
evazion db0bcf08b9 Post#approve!: move approving logic to post_approval.rb. 2017-04-03 17:18:31 -05:00
evazion 258fc37bfe Post#approve!: move validation to post_approval.rb 2017-04-03 17:18:31 -05:00
evazion 4b138be6b9 Rewrite i.pximg.net manga gallery samples. 2017-04-03 17:17:22 -05:00
evazion af4708dde9 Fix typo in i.pximg.net download strategy. 2017-04-03 17:17:22 -05:00
evazion 3c89ee3199 tests: add more post/pool version creation tests.
Adds the `test_after_commit` gem too because after_commit callbacks
don't fire inside tests in rails <5.0.
2017-04-03 15:03:59 -07:00
evazion 8fff3315f2 fix #2950: don't send versions to archives if save fails. 2017-04-03 15:03:58 -07:00
evazion 1ae5b7ba2f post archives: fix N+1 problem when fetching previous version. 2017-04-03 15:03:26 -07:00
evazion 964197d403 upload tags report: fix N+1 queries issues. 2017-04-03 15:03:26 -07:00
evazion 765fbac11d /reports/upload_tags: show thumbnails instead of post ids. 2017-04-03 15:03:26 -07:00
evazion fdd8ebb1b8 /users/1234: link to upload tag changes report. 2017-04-03 15:03:26 -07:00
evazion 25b2b399cc saved searches: fix exception when searching for search:adfijoioi.
Fixes this exception:

    NoMethodError exception raised

    undefined method `empty?' for nil:NilClass
    app/logical/post_query_builder.rb:113:in `block in add_saved_search_relation'
    app/logical/post_query_builder.rb:106:in `each'
    app/logical/post_query_builder.rb:106:in `add_saved_search_relation'
    app/logical/post_query_builder.rb:237:in `build'
    app/models/post.rb:1624:in `tag_match'
    app/models/post.rb:1172:in `block in fast_count_search'
    config/initializers/active_record_extensions.rb:16:in `with_timeout'
    app/models/post.rb:1171:in `fast_count_search'
    app/models/post.rb:1162:in `fast_count'
    app/logical/post_sets/post.rb:106:in `get_post_count'
    app/logical/post_sets/post.rb:122:in `posts'
    app/controllers/posts_controller.rb:15:in `index'

caused by this failure in listbooru when you send it an empty array as the list of queries:

    Redis::CommandError - ERR wrong number of arguments for 'zunionstore' command:

    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/redis-3.3.3/lib/redis/client.rb:121:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/redis-3.3.3/lib/redis.rb:1932:in `block in zunionstore'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/redis-3.3.3/lib/redis.rb:58:in `block in synchronize'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/redis-3.3.3/lib/redis.rb:58:in `synchronize'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/redis-3.3.3/lib/redis.rb:1931:in `zunionstore'
    web/listbooru.rb:85:in `aggregate_searches'
    web/listbooru.rb:104:in `block in <main>'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1611:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1611:in `block incompile!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:975:in `block (3 levels) in route!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:994:in `route_eval'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:975:in `block (2 levels) in route!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1015:in `block inprocess_route'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1013:in `catch'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1013:in `process_route'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:973:in `block in route!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:972:in `each'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:972:in `route!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1085:in `block indispatch!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `block ininvoke'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `catch'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `invoke'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1082:in `dispatch!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:907:in `block in call!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `block ininvoke'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `catch'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1067:in `invoke'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:907:in `call!'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:895:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-1.6.5/lib/rack/logger.rb:15:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-1.6.5/lib/rack/commonlogger.rb:33:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:219:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:212:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-1.6.5/lib/rack/head.rb:13:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-1.6.5/lib/rack/methodoverride.rb:22:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/show_exceptions.rb:25:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:182:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:2013:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1487:in `block incall'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1787:in `synchronize'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/sinatra-1.4.8/lib/sinatra/base.rb:1487:in `call'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rack-1.6.5/lib/rack/handler/webrick.rb:88:in `service'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/2.4.0/webrick/httpserver.rb:140:in `service'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/2.4.0/webrick/httpserver.rb:96:in `run'
    /home/admin/.rbenv/versions/2.4.1/lib/ruby/2.4.0/webrick/server.rb:290:in `block in start_thread'
2017-04-03 15:03:26 -07:00
evazion 5f1b7f48f7 Fix exception when autotagging animated_gifs.
Fixes this exception caused by the animated_gif autotagger trying to access the
image file, which fails if the image is not hosted on the webserver.

Magick::ImageMagickError exception raised

    unable to open image `/var/www/danbooru2/releases/20170322212609/public/data/f0e32c0e2d906c4932858866346f98b5.gif': No such file or directory @ error/blob.c/OpenBlob/2712
    app/models/post.rb:177:in `ping'
    app/models/post.rb:177:in `is_animated_gif?'
    app/models/post.rb:684:in `add_automatic_tags'
    app/models/post.rb:638:in `normalize_tags'
    app/controllers/posts_controller.rb:49:in `update'
2017-03-26 18:12:13 -05:00
evazion 26e8b7144a Fix exception in h(post.source) when source is nil (fixes #2940).
Fixes this exception:

    TypeError exception raised

    no implicit conversion of nil into String
    app/presenters/presenter.rb:3:in `escapeHTML'
    app/presenters/presenter.rb:3:in `h'
    app/presenters/post_presenter.rb:91:in `data_attributes'
    app/presenters/post_presenter.rb:24:in `preview'
    app/presenters/post_set_presenters/base.rb:15:in `block in post_previews_html'
    app/presenters/post_set_presenters/base.rb:14:in `post_previews_html'
    app/views/posts/partials/index/_posts.html.erb:3:in `_app_views_posts_partials_index__posts_html_erb___2716396856929289512_70158315986180'
    app/views/posts/index.html.erb:39:in `_app_views_posts_index_html_erb__1345252938355811220_70158296799280'
    app/controllers/posts_controller.rb:16:in `index'
2017-03-25 23:43:20 -05:00
evazion 163d338874 post_vote_test.rb: add more voting tests. 2017-03-24 15:43:55 -05:00
evazion 4470828a3d post_test.rb: add tests for moving favorites. 2017-03-24 15:43:55 -05:00
evazion a5ecda2f0e post_test.rb: fix voting tests. 2017-03-24 15:43:55 -05:00
evazion 3dc854c0c8 post_vote.rb: determine vote magnitude from voter, not CurrentUser.
Bug: when moving favorites, the parent is given an upvote for each gold+
favoriter, but the magnitude of these upvotes was based on the
CurrentUser, rather than the upvoter. This meant that upvotes for
supervoter favorites weren't given correctly.

To fix this, `magnitude` is changed to use the voting `user` instead of
CurrentUser.

New problem: when setting the score, `score=` calls `magnitude`, but
`user` isn't initialized yet. So we also refactor so that

    1. `initialize_attributes` initializes `user` before setting `score`
    2. the vote direction is given by `vote`, so it's separate from `score`
    3. updating the score on the post happens in a callback instead of
       directly in `score=`.
2017-03-24 15:43:55 -05:00
evazion 07707b257a post.rb: make non-gold supervoters upvote when fav'ing a post. 2017-03-24 15:43:55 -05:00
evazion fd24ea5876 posts.rb: vote on behalf of correct user when moving favorites.
Bug: when an approver moves the favorites of a post, each favorite is
removed from the child post and added to the parent post. For gold+
users, this triggers an upvote, but these upvotes were performed by the
approver rather than the favoriter.
2017-03-24 15:43:28 -05:00
evazion 73b19bee05 Fix exception in h(post.source) when source is nil.
Fixes this exception:

    TypeError exception raised

    no implicit conversion of nil into String
    app/presenters/presenter.rb:3:in `escapeHTML'
    app/presenters/presenter.rb:3:in `h'
    app/presenters/post_presenter.rb:91:in `data_attributes'
    app/presenters/post_presenter.rb:24:in `preview'
    app/presenters/post_set_presenters/base.rb:15:in `block in post_previews_html'
    app/presenters/post_set_presenters/base.rb:14:in `post_previews_html'
    app/views/posts/partials/index/_posts.html.erb:3:in `_app_views_posts_partials_index__posts_html_erb___2716396856929289512_70158315986180'
    app/views/posts/index.html.erb:39:in `_app_views_posts_index_html_erb__1345252938355811220_70158296799280'
    app/controllers/posts_controller.rb:16:in `index'
2017-03-24 00:26:54 -05:00
evazion 66b5dc641c /moderator/dashboard: use PostPresenter.preview for appeal thumbnails. 2017-03-23 04:05:06 -05:00
evazion 246eb1e8ab db: add created_at indexes on post_appeals, artist/note/wiki_page versions,
This optimizes queries on /moderator/dashboard that filter by creation date.
2017-03-23 04:05:06 -05:00
evazion d1d0fe9bc5 /moderator/dashboard: optimize sql queries
* Converts queries to use active record instead of raw sql. This ensures
  that user objects are loaded by rails in the join, so that we
  don't have to issue `User.find` calls to load users one-by-one.

* Use `.includes` to preload associations used in the view, to avoid
  additional N+1 query problems (primarily, calls to link_to_user
  also causing users to be loaded one-by-one).
2017-03-23 04:05:05 -05:00
evazion 90cd029f6f wiki excerpts: show alias/implication lists even for tags without a wiki. 2017-03-23 03:54:42 -05:00
evazion 8918e301b4 alias_and_implication_list: add help links for aliases/implications. 2017-03-23 03:36:16 -05:00
evazion 267d70bd52 Fix #2931: mention automated implications on *_(cosplay) wikis. 2017-03-23 03:35:27 -05:00
evazion f40e50d915 sqs_service.rb: fix exception when related tags sqs not configured.
Fixes this exception when Danbooru.config.aws_sqs_enabled? is true but
Danborou.config.aws_sqs_reltagcalc_url is not configured:

    ArgumentError exception raised

    missing required parameter params[:queue_url]
    app/logical/sqs_service.rb:11:in `send_message'
    app/models/tag.rb:674:in `update_related_if_outdated'
    app/models/tag.rb:698:in `related_tag_array'
    app/presenters/post_set_presenters/post.rb:49:in `related_tags_for_single'
    app/presenters/post_set_presenters/post.rb:19:in `related_tags'
    app/presenters/post_set_presenters/post.rb:8:in `initialize'
    app/logical/post_sets/post.rb:181:in `new'
    app/logical/post_sets/post.rb:181:in `presenter'
    app/views/posts/index.html.erb:14:in `_app_views_posts_index_html_erb___3235672853362939702_47243208308540'
    app/controllers/posts_controller.rb:16:in `index'
2017-03-23 03:20:33 -05:00
evazion 4fde2a26fb post.rb: handle automatic *_(cosplay) tags in TagImplication. 2017-03-23 02:48:03 -05:00
evazion 0793beded9 alias_and_implication_list: refactor alias/implication lookup.
Add alias and implications associations to Tag. Use them in
alias_and_implication list instead of duplicating the alias/implication
lookup code.
2017-03-23 02:47:21 -05:00
evazion d1debecd0b Fix XSS in post thumbnail data attributes. 2017-03-21 17:17:19 -05:00
evazion 2aa3f9ceba /moderator/dashboard: fix exception when PostArchive isn't enabled.
NoMethodError exception raised

    undefined method `each' for nil:NilClass
    app/views/moderator/dashboards/_activity_tag.html.erb:10:in `_app_views_moderator_dashboards__activity_tag_html_erb__4366063041301266690_47304449138520'
    app/views/moderator/dashboards/show.html.erb:10:in `_app_views_moderator_dashboards_show_html_erb___734721021521262965_47304462731220'
2017-03-21 17:17:19 -05:00
evazion 47ecf034a7 /posts/:id/events - fix exception when viewed by mod.
NoMethodError exception raised

    undefined method `creator' for #<PostEvent:0x007f9a298e64d8> Did you mean? creator_id
    app/views/post_events/index.html.erb:23:in `block in _app_views_post_events_index_html_erb__2088986421112502721_70150054247640'
    app/views/post_events/index.html.erb:18:in `each'
    app/views/post_events/index.html.erb:18:in `_app_views_post_events_index_html_erb__2088986421112502721_70150054247640'
    app/controllers/post_events_controller.rb:6:in `index'
2017-03-21 17:17:18 -05:00
evazion 85d1f18ba5 comments: make commenter ip addresses visible to mods. 2017-03-19 23:41:25 -05:00
evazion 396d466a9b /posts/:id - make flagger/appealer ip addresses visible to mods. 2017-03-19 23:41:09 -05:00
evazion 5ba1df5502 /posts/:id/events: list is_resolved correctly for appeals.
/posts/:id/events incorrectly lists appeals as always being resolved.
This is because events UNION together appeals and flags, which doesn't
quite work because for appeals is_resolved is a method, not an
attribute. is_resolved was hardcoded to true so it'd work in the UNION.

This changes PostEvent to be a wrapper object around PostFlag /
PostAppeal, instead of a UNION. PostEvent delegates everything to the
inner flag/appeals object, so that is_resolved works correctly.

Also, this incidentally fixes a problem with /posts/:id/event.xml not
serializing correctly.
2017-03-19 22:47:10 -05:00
evazion 8341752931 fixup! /moderator/dashboard: fix post version reference. 2017-03-19 17:02:39 -05:00
evazion cebf592e20 /moderator/dashboard: fix post version reference. 2017-03-18 05:18:01 -05:00
evazion eda97dc1ff /posts: add notice when posts are hidden. 2017-03-17 00:08:48 -05:00
evazion 935cefd27e API: on error, include backtrace in json response.
Incidentally fixes issue with error responses inside /sources.json not
including the usual `{"success": false}`.
2017-03-16 18:11:43 -05:00
evazion 28bdfce9f6 /sources: add /sources.xml endpoint. 2017-03-16 18:10:30 -05:00
evazion 2051981170 When merging artcomms, list source as html page url, not image url. 2017-03-16 18:09:59 -05:00
evazion ba408c8718 simple_form: regen config files (#2913).
Regens simple form config using `rails generate simple_form:install`.
Seems to fix #2913 (erroneous minlength validations being enforced as of
simple_form 3.4.0).
2017-03-03 17:21:37 -06:00
evazion 167d86d4ec Fix 'Posts Report "Reviewed by 0 Moderators"' (#2914). 2017-03-03 15:35:01 -06:00
evazion d4b9b66c0e post_versions_controller.rb: fix N+1 queries in post, updater.
Rendering the updater name at post_versions/_listing.html:25 caused
this for each post version:

    SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1

PostArchive#diff caused this for each post version:

    SELECT "posts".* FROM "posts" WHERE "posts"."id" = $1 LIMIT 1
2017-03-02 17:47:20 -06:00
evazion 3290f5550a post_versions/_listing.html.erb:40: fix N+1 queries in "Undo" link.
post_version.post.versions.first.id caused an extra query for each post version:

    SELECT "post_versions".* FROM "post_versions" WHERE "post_versions"."post_id" = $1 ORDER BY updated_at ASC, id asc LIMIT 1
2017-03-02 17:46:14 -06:00
evazion f13f9e7163 post_versions/index.html.erb:5: avoid extraneous COUNT.
@post_versions.empty? caused this query:

    SELECT COUNT(count_column) FROM (SELECT 1 AS count_column FROM "post_versions" WHERE (true) LIMIT 20 OFFSET 0) subquery_for_count

which is unnecessary since @post_versions can be counted directly.
2017-03-02 17:45:20 -06:00
evazion 3db7244109 post_archive.rb: readd associations. 2017-03-02 17:45:16 -06:00
evazion 02122343c3 dmails: don't default IP addr to 127.0.0.1 in database (fixes #2908).
Bug introduced in 1400f64; that commit changed dmails so that
creator_ip_addr defaulted to CurrentUser.ip_addr like this:

    after_initialize :initialize_attributes, if: :new_record?

    def initialize_attributes
      self.from_id ||= CurrentUser.id
      self.creator_ip_addr ||= CurrentUser.ip_addr
    end

...but creator_ip_addr already defaulted to 127.0.0.1 from the database,
so the ||= assignment didn't work. Remove the database default so we
always default to CurrentUser.ip_addr.
2017-03-01 19:51:48 -06:00
evazion 2bb134f08d modqueue: highlight uploads containing "bad" tags. 2017-03-01 15:31:16 -06:00
evazion 21e76d55e6 Remove extraneous byte-ordering marks. 2017-02-28 19:01:10 -06:00
evazion 5fffbb4be5 stylesheets: fix @import "*.css.scss" to "*.scss". 2017-02-28 19:01:10 -06:00
evazion df3925ecb4 stylesheets: rename *.css.scss -> *.scss.
Fixes "DEPRECATION WARNING: Extra .css in SCSS file is unnecessary."
2017-02-28 19:01:09 -06:00
evazion c7e276abff Gemfile.lock: update rails to 4.2.8. 2017-02-28 00:11:27 -06:00
evazion 204fbd811c Gemfile.lock: update dalli to 2.7.6. 2017-02-28 00:11:27 -06:00
evazion ed894af675 Gemfile.lock: update responders to 2.3.0. 2017-02-28 00:11:27 -06:00
evazion 076c409b0d Gemfile.lock: update rmagick to 2.16.0. 2017-02-28 00:11:27 -06:00
evazion 722a672aef Gemfile.lock: update whenever to 0.9.7. 2017-02-28 00:11:27 -06:00
evazion bfb0c08e8c Gemfile.lock: update mechanize to 2.7.5. 2017-02-28 00:11:27 -06:00
evazion 2a05b81f43 Gemfile.lock: update simple_form to 3.4.0. 2017-02-28 00:11:26 -06:00
evazion af1c1004f7 Gemfile.lock: update delayed_job to 4.1.2. 2017-02-28 00:11:26 -06:00
evazion 176f5775b4 Gemfile.lock: update sass-rails to 5.0.6. 2017-02-28 00:11:26 -06:00
evazion 9d3a4101c4 Gemfile.lock: update uglifier to 3.0.4. 2017-02-28 00:11:26 -06:00
evazion 742afd1b72 Gemfile.lock: update pg to 0.19.0. 2017-02-28 00:11:26 -06:00
evazion 4ede0c4166 Gemfile.lock: update ffaker to 2.5.0. 2017-02-28 00:11:25 -06:00
evazion 59bb705307 Gemfile.lock: update awesome_print to 1.7.0. 2017-02-28 00:11:25 -06:00
evazion 822d881096 Gemfile.lock: update pry-byebug to 3.4.2. 2017-02-28 00:11:25 -06:00
evazion bdbf54aef7 Gemfile: remove unused gems.
coffee-rails and daemons are unused.

kgio, net-ssh, and nokogiri are pulled in by other gems, but they aren't
used by us directly, so they shouldn't need to be listed in the Gemfile.
2017-02-28 00:11:25 -06:00
evazion 615e4bbebd Gemfile: move test group to bottom. 2017-02-28 00:11:25 -06:00
evazion 46280f2227 mentions: include mentioner in subject line.
The template looks like this:

Subject:

    #{creator_name} mentioned you in a comment on post ##{post_id}

Body:

    @#{creator_name} mentioned you in a \"comment\":/posts/#{post_id}#comment-#{id} on post ##{post_id}:

    [quote]
    #{DText.excerpt(body, "@"+user_name)}
    [/quote]
2017-02-25 23:05:44 -06:00
evazion 6994231801 mentions: send dmails from DanbooruBot. 2017-02-25 23:05:44 -06:00
evazion 6e3ddb6ed6 dmails: don't save copies of outgoing dmails sent by DanbooruBot.
There's not much sense in saving copies of everything DanbooruBot sends
in DanbooruBot's inbox. They probably won't be checked so it just bloats
the dmails table.
2017-02-25 23:05:44 -06:00
evazion 40092f21ba Remove redundant rescue_from calls.
These are redundant because ApplicationController rescues these exceptions already.
2017-02-25 02:18:16 -06:00
evazion 6966b74e18 Disallow unicode whitespace in usernames (#2894). 2017-02-25 01:51:33 -06:00
evazion b80976bce7 modqueue: link tags, like they are in /comments. 2017-02-24 21:03:14 -06:00
evazion 83915a5d46 modqueue: avoid N+1 queries for disapprovals, uploaders.
Fixes an N+1 queries problem in the /moderator/post/queue view by
prefetching disapprovals and uploaders.

Also the way disapproval messages were previously rendered triggered a bunch
of sql queries for each post:

    SELECT COUNT(*) FROM "post_disapprovals" WHERE "post_disapprovals"."post_id" = $1 [["post_id", 52]]
    SELECT COUNT(*) FROM "post_disapprovals" WHERE "post_disapprovals"."post_id" = $1 AND "post_disapprovals"."reason" = $2  [["post_id", 52], ["reason", "breaks_rules"]]
    SELECT COUNT(*) FROM "post_disapprovals" WHERE "post_disapprovals"."post_id" = $1 AND "post_disapprovals"."reason" = $2  [["post_id", 52], ["reason", "poor_quality"]]
    SELECT COUNT(*) FROM "post_disapprovals" WHERE "post_disapprovals"."post_id" = $1 AND "post_disapprovals"."reason" IN ('disinterest', 'legacy')  [["post_id", 52]]
    SELECT COUNT(*) FROM "post_disapprovals" WHERE "post_disapprovals"."post_id" = $1 AND (message is not null and message <> '')  [["post_id", 52]]
    SELECT "post_disapprovals".* FROM "post_disapprovals" WHERE "post_disapprovals"."post_id" = $1 AND (message is not null and message <> '')  [["post_id", 52]]

This refactors to bring it down to one:

    SELECT "post_disapprovals".* FROM "post_disapprovals" WHERE "post_disapprovals"."post_id" = $1  [["post_id", 52]]
2017-02-24 21:03:14 -06:00
evazion 9b40016895 /posts/NNN, modqueue: allow dtext in disapproval reasons. 2017-02-24 21:03:14 -06:00
evazion 6704e71377 dmails: add tests for automated dmails. 2017-02-23 22:51:17 -06:00
evazion b1af644f67 dmails: send automated dmails from Danbooru.config.system_user.
Sends automated dmails from `Danbooru.config.system_user`, rather than
whichever user is performing the action happens to be (usually User.admins.first).

Also adds a notice in the view that the dmail was automated.
2017-02-23 22:51:17 -06:00
evazion 1400f64338 dmails_controller.rb: convert to strong params. 2017-02-23 22:51:17 -06:00
evazion 0c4b687880 user_name_change_requests.rb: remove unused notify_admins callback. 2017-02-23 22:51:17 -06:00
evazion 865211b0b5 dmails: remove unused edit template and update route. 2017-02-23 22:51:17 -06:00
evazion 2d8a7ed93b /dmails: add help:dmail link to subnavbar. 2017-02-23 22:51:17 -06:00
evazion d852f98e4f /dmails: remove unused search[owner_id] param.
/dmails is restricted to viewing dmails for CurrentUser only (due to
Dmail.visible in the index action). Remove owner_id from subnavbar links
in /dmails, and don't support it in /dmails?search[owner_id], since it
doesn't actually do anything.

Also removes related dead methods and fixes tests that didn't test owner_id properly.
2017-02-23 22:51:17 -06:00