Commit Graph

46 Commits

Author SHA1 Message Date
evazion
f8db577c25 dmails: replace hard deletions with soft deletions.
Turn deletions into soft deletions (set the is_deleted flag) instead of
hard deletions (remove from database). The is_deleted flag actually
already existed, but it was never used before.
2020-01-31 16:24:27 -06:00
evazion
5df8d08aae dmails: allow Members to mark dmails as spam.
* Allow Members to mark dmails as spam or not spam (previously Gold only).
* Replace spam and ham endpoints with single update endpoint.
2020-01-31 02:43:08 -06:00
evazion
c7185724d5 controllers: set @current_item globally in respond_with. 2020-01-31 02:43:08 -06:00
BrokenEagle
223a6df5d8 Add API data to show/index views 2020-01-04 22:02:44 +00:00
evazion
309821bf73 rubocop: fix various style issues. 2019-12-22 21:23:37 -06:00
evazion
6424a4de74 Do full page counts on small index pages.
Normally we skip doing page counts on index pages when there aren't any
search filters. This is on the assumption that most index pages have
more than 1000 pages (20,000 results), so it's not worth counting them
exactly. This isn't always true, so here we turn on full counts on
certain index pages known to be small.
2019-10-28 15:18:54 -05:00
evazion
a5ab25d0ba pagination: avoid counting pages outside searches.
Replace this common pattern in controllers:

    @tags = Tag.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search])

with this:

    @tags = Tag.paginated_search(params)

`search_count` is used to skip doing a full page count when we're not
doing a search (on the assumption that the number of results will be
high when not constrained by a search). We didn't do this consistently
though. Refactor to do this in every controller.
2019-10-07 22:02:03 -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
06ff249530 dmails: factor out spam detector service. 2019-08-23 22:38:03 -05:00
Albert Yi
990d625ae3 reset unread dmail count when using mark all as read (#3574) 2018-04-26 11:47:07 -07: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
BrokenEagle
d829ab3a00 Move all order logic to models
- Have a default order for each model
-- The overall default is ID DESC
- Allow for custom orderings
-- When comma-separated IDs are used
2018-01-29 11:42:53 -08:00
r888888888
b944b642b8 akismet integration 2017-09-14 13:37:36 -07:00
evazion
ef1db967f7 /dmails: allow banned users to read/delete dmails. 2017-07-06 18:39:42 -05:00
evazion
0652b907a9 dmails: inline search form on /dmails page. 2017-04-29 11:50:26 -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
1400f64338 dmails_controller.rb: convert to strong params. 2017-02-23 22:51:17 -06:00
Albert Yi
4eb0a64135 fix exploit for viewing private dmails 2016-12-06 14:34:46 -08:00
Type-kun
a718560554 Initial support for #2677 2016-09-17 16:42:00 +05:00
r888888888
67e46f6e5c fixes #2418 (includes hiding deleted dmails and allowing filtering on user name) 2015-07-07 17:32:38 -07:00
r888888888
ff86f3c298 fix bitpref references 2014-06-23 18:00:31 -07:00
Toks
079853656e Fix marking all dmails as read not working fully 2014-03-29 16:27:41 -04:00
Toks
59f5fc2e1f Fix issue when deleting unread dmail 2014-03-29 16:27:18 -04:00
r888888888
10516c9834 fixes #2100 2014-02-21 13:46:45 -08:00
Toks
f570b9b70d Add quick search for #1868 2013-07-21 17:24:59 -04:00
Toks
1024d24298 fixes #1842 2013-07-07 18:17:15 -04:00
Toks
6897733aab fixes #1809 2013-06-25 17:51:50 -04:00
r888888888
360e945ed6 fixes #1656 2013-05-24 13:13:21 -07:00
Toks
9ccf1e0f8f add limit parameter to everything 2013-05-15 01:01:19 -04:00
Toks
3d98d4b4ec fixes #1491 2013-05-07 22:18:11 -04:00
albert
541dabaaf6 fixes #1108 2013-03-29 15:37:28 -04:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
78f1d0f69a fixes to user search 2013-02-21 12:42:41 -05:00
albert
65b45e46c2 add mark all dmail as read option 2013-02-20 22:52:42 -05:00
albert
eb5e526678 enable uploads 2013-02-17 21:39:15 -05:00
albert
44682156c0 fix searches 2013-02-17 21:09:25 -05:00
albert
a3821d0397 fixes #250 2012-01-13 18:28:01 -05:00
albert
37e2d36e8b fix for #219 2012-01-06 19:24:20 -05:00
albert
cb0f8d5377 dmail paginator fix 2011-12-07 17:04:54 -05:00
albert
ee1329235d fix to install script, add ordering to dmails 2011-12-07 16:58:52 -05:00
albert
1e49a00150 fixes to dmail ui 2011-10-16 01:58:16 -04:00
albert
9649e7f40a test fxies 2011-07-22 18:26:55 -04:00
albert
c0968ec5e3 tag subscriptions 2011-01-30 02:24:47 -05:00
albert
46164eab4f finished dmails and favorites functional tests 2010-12-05 22:27:45 -05:00
albert
c6304c6e08 views 2010-11-19 16:24:17 -05:00
albert
ac98d7db37 stubbed in blank controllers/helpers/functional tests 2010-03-10 18:21:43 -05:00