Commit Graph

123 Commits

Author SHA1 Message Date
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
be36968b6d Fix #3351: Mod+: Treat deleted comments as below score threshold.
Comments have three states: visible, hidden, and invisible. Visible
comments are always shown. Hidden comments are not shown until the user
clicks 'Show all comments'. Invisible comments are never shown to the
user. Deleted comments are treated as hidden for moderators and
invisible for normal users. Thresholded comments are treated as hidden
for all users.
2019-08-31 16:24:44 -05:00
evazion
a3d748e300 Fix #4145: Unable to view deleted comments from post page.
Bug: if all the comments on a post were deleted then the deleted
comments wouldn't be visible to moderators.

This was because we assumed that if `last_commented_at` was nil it meant
that the post had no comments, but this was wrong. `last_commented_at`
only counts undeleted comments. It's reset to nil if all the commnets
have been deleted.
2019-08-26 13:50:42 -05:00
evazion
831aa57cad posts/show: fix thresholded comments not being hidden on pageload. 2019-08-22 16:40:45 -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
798d524e60 Post#tag_match: clean up read_only param.
* Drop /posts?ro=true param (broken).
* Clean up tag_match (rescuing PG::ConnectionBad didn't do anything, we
  just build the query here, we don't run it).
2019-08-16 00:26:00 -05:00
evazion
dbfd6185f1 posts: fix error on /posts?md5=<does_not_exist>. 2019-08-13 21:30:21 -05:00
Albert Yi
a12f6badde add RequestStore gem, support universal only param for api endpoints (fixes #4068) 2019-04-17 12:00:42 -07:00
evazion
19b92acabc Fix #3970: Make "Copy all notes" not builder exclusive. 2018-11-04 16:42:55 -06:00
evazion
39374a70d3 posts/show: rename tags params to q in various places.
Fixup for 011a6f1f7.
2018-10-30 11:32:07 -05:00
evazion
d536f75505 related tags: eliminate recent_tags cookie (#3955). 2018-10-12 21:20:06 -05:00
evazion
f886f2fdb3 posts/show: load flag/appeal/replacement dialogs via ajax (#3922). 2018-09-26 20:01:14 -05:00
evazion
6fe883c316 posts index: clean up limit:<n> / order:random parsing (#2894)
* Move the limit:<n> / order:random metatag parsing from the controller
  to the post set.

* Introduce `Tag.has_metatag?` and use it to parse these metatags
  instead of using a regex (#2894).
2018-09-20 19:23:47 -05:00
evazion
e772de40a7 posts: add /posts/{id}.html?variant=tooltip template. 2018-04-25 22:12:26 -05:00
r888888888
abce4d2551 Raise error on unpermitted params.
Fail loudly if we forget to whitelist a param instead of silently
ignoring it.

misc models: convert to strong params.

artist commentaries: convert to strong params.

* Disallow changing or setting post_id to a nonexistent post.

artists: convert to strong params.

* Disallow setting `is_banned` in create/update actions. Changing it
  this way instead of with the ban/unban actions would leave the artist in
  a partially banned state.

bans: convert to strong params.

* Disallow changing the user_id after the ban has been created.

comments: convert to strong params.

favorite groups: convert to strong params.

news updates: convert to strong params.

post appeals: convert to strong params.

post flags: convert to strong params.

* Disallow users from setting the `is_deleted` / `is_resolved` flags.

ip bans: convert to strong params.

user feedbacks: convert to strong params.

* Disallow users from setting `disable_dmail_notification` when creating feedbacks.
* Disallow changing the user_id after the feedback has been created.

notes: convert to strong params.

wiki pages: convert to strong params.

* Also fix non-Builders being able to delete wiki pages.

saved searches: convert to strong params.

pools: convert to strong params.

* Disallow setting `post_count` or `is_deleted` in create/update actions.

janitor trials: convert to strong params.

post disapprovals: convert to strong params.

* Factor out quick-mod bar to shared partial.
* Fix quick-mod bar to use `Post#is_approvable?` to determine visibility
  of Approve button.

dmail filters: convert to strong params.

password resets: convert to strong params.

user name change requests: convert to strong params.

posts: convert to strong params.

users: convert to strong params.

* Disallow setting password_hash, last_logged_in_at, last_forum_read_at,
  has_mail, and dmail_filter_attributes[user_id].

* Remove initialize_default_image_size (dead code).

uploads: convert to strong params.

* Remove `initialize_status` because status already defaults to pending
  in the database.

tag aliases/implications: convert to strong params.

tags: convert to strong params.

forum posts: convert to strong params.

* Disallow changing the topic_id after creating the post.
* Disallow setting is_deleted (destroy/undelete actions should be used instead).
* Remove is_sticky / is_locked (nonexistent attributes).

forum topics: convert to strong params.

* merges https://github.com/evazion/danbooru/tree/wip-rails-5.1
* lock pg gem to 0.21 (1.0.0 is incompatible with rails 5.1.4)
* switch to factorybot and change all references

Co-authored-by: r888888888 <r888888888@gmail.com>
Co-authored-by: evazion <noizave@gmail.com>

add diffs
2018-04-06 18:09:57 -07:00
evazion
7a0fb0f5d3 Fix #3500: Redirect API endpoints with md5 query param to correct format. 2018-01-14 20:36:57 -06:00
evazion
07a4bdcb21 posts: display validation warnings in flash notice. 2017-11-25 17:03:32 -06:00
r888888888
d0ccce6985 fixes #3350 2017-11-07 11:56:26 -08:00
evazion
45676491ff Post.fast_count: remove uses of unused statement_timeout param (#3206).
Not used since 81684e6.
2017-07-14 17:35:42 -05: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
23038de470 posts_controller.rb: remove unused /posts/home action.
Unused since a4911e3.
2017-02-06 19:07:03 -06:00
r888888888
bfa56a860c fixes #2415: "Random post" causes RecordNotFound exceptions 2017-01-18 14:12:12 -08:00
Albert Yi
bdac591266 fixes #2838 2017-01-16 12:57:43 -08:00
evazion
ef3f390bba Fix #2813: /posts/random.json does not redirect nicely. 2017-01-01 04:04:46 -06:00
evazion
c46b31aa9c Prevent reverting to foreign versions (fixes #2711). 2016-10-11 06:57:46 +00:00
r888888888
2c80d7b82e more intelligent notice for mod queue 2016-09-09 15:08:23 -07:00
r888888888
3542ffe1f7 refactor inactive janitor notice 2016-09-09 14:30:35 -07:00
r888888888
1682196490 fix role 2016-09-08 16:02:51 -07:00
r888888888
de34c7fca3 fixes #2650: Add random mode to mod queue 2016-09-08 15:55:06 -07:00
r888888888
9d3d7abedc add support for read only post queries 2016-01-25 16:40:23 -08:00
Toks
7c7f92d1b2 Fix errors saving recent tags not displaying correctly 2015-11-08 15:07:01 -05:00
r888888888
d8f639e721 fixes #2444 2015-07-21 13:42:32 -07:00
r888888888
6ad6aa44c4 fixes #2432, fix tests 2015-07-14 15:13:04 -07:00
Toks
f3e4aa51f0 preserve favgroup_id 2015-06-25 10:45:26 -04:00
Toks
eb560be34b #2415 remove ordering from random post link 2015-06-22 14:23:59 -04:00
Toks
3bc92f1ca7 #1938 Add order:random as alternative random trigger 2015-06-09 18:15:50 -04:00
Toks
6a78d75f61 Fix "mark as translated" removing url params 2015-05-23 12:26:31 -04:00
Toks
0d24a45855 fixes #1938, Add special random parameter 2015-05-17 20:06:31 -04:00
Toks
8c63bf5b72 fixes #1495 2015-05-13 18:25:01 -04:00
Toks
f060e78b8f fix #2196 2014-06-16 20:07:52 -04:00
Toks
3f61415388 Merge branch 'active-children' 2014-05-29 23:03:05 -04:00
Toks
71cd5ce783 fixes #2114 2014-05-29 22:55:35 -04:00
Toks
5f12a5e555 fixes #2165 2014-05-25 14:50:07 -04:00
r888888888
6630bd9a41 fixes #2161 2014-05-22 17:52:05 -07:00
Toks
cac73439bd Fix error 2013-12-24 20:24:19 -05:00
Toks
8c95f13b11 Fix post relationship previews not always displaying deleted parents 2013-12-23 12:30:06 -05:00
r888888888
1da18ae57b fixes #2020 2013-12-03 17:26:04 -08:00
Toks
344180a7bd fixes #1836 2013-11-29 18:04:37 -05:00
r888888888
8296b9a26f remove debug logging 2013-10-08 15:24:27 -07:00
r888888888
892d62fac3 fixes #1982 2013-10-07 17:59:43 -07:00