Commit Graph
100 Commits
Author SHA1 Message Date
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
evazion 6de350cd7d dmail.rb: remove dead new_blank method. 2017-02-23 22:51:17 -06:00
evazion 35bf995276 dmail.rb: make to_name= use User.name_to_id cache. 2017-02-23 22:51:17 -06:00
evazion 2736d31c67 dmail.rb: validate only on creation.
to/from/title/body don't need to be revalidated after creation since
they never change.
2017-02-23 22:51:16 -06:00
evazion abae71c060 layouts/default.html.erb: optimize dmail notice sql.
* CurrentUser.dmail_count caused an unnecessary COUNT(*).
* CurrentUser.dmails.unread.present? caused *all* unread dmails to be
  loaded. We want to only load the first one.
2017-02-18 05:54:46 -06:00
evazion d9349704c7 dmails: add indexes on is_read and is_deleted (fix #2886). 2017-02-18 05:54:40 -06:00
evazion 17d4feaf15 dmail_notice.html.erb: use absolute urls in dtext links. 2017-02-18 03:11:35 -06:00
evazion d78c537ec2 Add user mailer previewer.
Usage: open /rails/mailers in your browser.
2017-02-18 03:10:49 -06:00
evazion ebff8d04f7 config/application.rb: set hostname so root_url works. 2017-02-18 03:10:42 -06:00
evazion c926f75918 fixup! post.rb: validate newly added tags. 2017-02-09 02:14:48 -06:00
evazion f971f927fd post_test.rb: add tag name validation tests. 2017-02-08 23:31:30 -06:00
evazion facf819620 post.rb: validate newly added tags.
Existing tags with invalid names are still permitted. This is to allow
for a gradual transition to good tag names.
2017-02-08 23:31:30 -06:00
evazion 347f11b935 post.rb: group validation methods together. 2017-02-08 23:31:30 -06:00
evazion 8e3296f3ea tag.rb: don't strip '%' or ',' from tags; split on unicode spaces.
Allows '%' and ',' in tag names. There's no technical need to forbid
these characters.

Fixes an issue with these characters being stripped away inside metatags
(e.g. tagging a post with `pool:ichigo_100%` strips away the '%').
2017-02-08 23:31:30 -06:00
evazion 853ddc7cda tag.rb: validate tag names.
Makes these tag names invalid when tagging posts:

* Blank names (e.g. ___).
* Non-ASCII characters (Japanese text).
* Non-printable characters (e.g. control characters < 0x20).
* Leading or trailing underscores, or consecutive underscores. Reason:
  `_foo__bar_` and `foo_bar` both render as `foo bar` in the tag list.
* Leading `-` or `~`, or '*' (-foo, ~foo, foo*bar). Previously
  these were silently stripped, but that meant tagging a post with e.g.
  `*-foo` tagged the post with the invalid tag `-foo`.
* Tag type prefixes (e.g. `character:character:hatsune_miku` no longer creates
  the literal tag `character:hatsune_miku`).
* Metatags (order:score, user:evazion, etc).
2017-02-08 23:30:23 -06:00
evazion 951e6d4b5f Remove unused arbitrary_sql_order_clause.
Unused since f87c71c.
2017-02-06 19:07:04 -06:00
evazion cf54cd1480 core_extensions.rb: remove unused String#to_escaped_js. 2017-02-06 19:07:04 -06:00
evazion b5bf9b8678 post.rb: remove assorted unused methods. 2017-02-06 19:07:03 -06:00
evazion 74b8ebe580 tag.rb: remove unused find_suggestions, increment_view_count.
find_suggestions unused since ca3e9bb.
2017-02-06 19:07:03 -06:00
evazion 23038de470 posts_controller.rb: remove unused /posts/home action.
Unused since a4911e3.
2017-02-06 19:07:03 -06:00
evazion 7e1f63de6a landings_controller.rb: remove unused /landing route.
Broken since PopularPostExplorer was removed in 7269ec0.
2017-02-06 19:07:03 -06:00
evazion 38355b4839 posts_helper.rb: remove unused resize_image_links.
Unused since 1ef7ef4.
2017-02-06 19:07:03 -06:00
evazion 4ded9c6b2a app/helpers: remove unused helpers. 2017-02-06 19:07:02 -06:00
evazion ec653dce71 app/presenters: remove unused forum_post/note/post_version presenters. 2017-02-06 19:07:02 -06:00
evazion 35b3398142 post_test.rb: add more metatag search tests. 2017-02-06 18:48:39 -06:00
evazion cac5eae3c4 tests: add more tags controller/model tests. 2017-02-06 18:48:39 -06:00
evazion 2b4c722bd1 tests: add more notes controller tests. 2017-02-06 18:48:38 -06:00
evazion 0890c6320b tests: add more comments controller tests. 2017-02-06 18:48:38 -06:00
evazion 73e274b2e0 tests: add more moderator/post/queues controller tests. 2017-02-06 18:48:38 -06:00
evazion a120a63d3b tests: add more moderator/post/posts controller tests. 2017-02-06 18:48:38 -06:00
evazion cdafbc849d tests: add more artist commentary controller tests. 2017-02-06 18:48:38 -06:00
evazion 2d62fff89b tests: add more wiki page versions controller tests. 2017-02-06 18:48:37 -06:00
evazion 43591e0c2d tests: add more wiki pages controller tests. 2017-02-06 18:48:37 -06:00
evazion 5c871aee64 tests: add more pools controller tests. 2017-02-06 18:48:37 -06:00
evazion dfb8d0106d tests: add more posts controller tests. 2017-02-06 18:48:37 -06:00
evazion 09ffac07ea tests: add more users controller tests. 2017-02-06 18:48:37 -06:00
evazion 3edd814be5 tests: add iqdb queries controller tests. 2017-02-06 18:48:37 -06:00
evazion e26fb61ee9 tests: add explore/posts controller tests. 2017-02-06 18:48:36 -06:00
evazion 443c41cff2 tests: add meta searches controller tests. 2017-02-06 18:48:36 -06:00
evazion 30c3a52187 tests: add mod actions controller test. 2017-02-06 18:48:36 -06:00
evazion 101a03e797 tests: add related tags controller tests. 2017-02-06 18:48:36 -06:00
evazion 423dfc13b8 tests: add sources controller tests. 2017-02-06 18:48:36 -06:00
evazion 142dc05d0c tests: add note previews controller tests. 2017-02-06 18:48:35 -06:00
evazion 77b4dfcdfb tests: add artist controller tests. 2017-02-06 18:48:35 -06:00
evazion 490864e24d tests: add saved searches controller tests. 2017-02-06 18:48:35 -06:00
evazion 64b4004bbf tests: add favorite groups controller tests. 2017-02-06 18:48:35 -06:00
evazion ed451b7199 tests: add reports controller tests. 2017-02-06 18:48:35 -06:00
evazion d74503ae05 tests: add misc controller tests. 2017-02-06 18:48:35 -06:00
evazion 8c75f74ca5 tests: update simplecov config. 2017-02-04 22:17:39 -06:00
evazion e8cf417e9c tests: update gems to latest versions.
Also fix a few things that broke under shoulda-matchers 3.1.1.
2017-02-04 22:17:15 -06:00
evazion dd5974bf8c test_helper.rb: use MemcacheMock. 2017-02-04 17:18:52 -06:00
evazion 9b16c45edc test_helper.rb: factor out upload test helpers. 2017-02-04 17:18:52 -06:00