Commit Graph

71 Commits

Author SHA1 Message Date
Albert Yi
99012ff342 fix tests 2018-05-09 11:59:51 -07:00
evazion
216d735f24 Fix #3696: API: handle boolean params consistently
* Use ApplicationRecord#attribute_matches to handle boolean attributes
  consistently in search methods.

* Add support for searching various boolean attributes that previously
  weren't supported.
2018-05-03 19:57:14 -05:00
evazion
c7492343ce String: add truthy? & falsy? core extensions.
* Add `truthy?` and `falsy?` core extensions to String.

* Use `truthy?` and `falsy?` to replace ad-hoc parsing of boolean
  parameters in various places.
2018-05-03 19:57:14 -05:00
Albert Yi
72e7f706df fix scoping bug in dmail 2018-04-27 15:04:27 -07:00
Albert Yi
664a3f02e2 fixes for failed cron maintenance tasks
* update rails scripts for 5.2
* system dmails should be scoped to system
* fix broken url generator in forum notices
2018-04-27 15:01:40 -07:00
Albert Yi
b0a3f574ed fixes #3574 2018-04-25 14:31:11 -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
evazion
1ca2497015 Fix #3474: Spurious email notifications. 2017-12-28 18:50:08 -06:00
evazion
0ca726802f Fix #3430: Accept the search[id] param in all controllers.
* Allow every controller to take the `search[id]` param.

* Parse the `search[id]` param the same way that the `id:<N>` metatag is
  parsed. So `search[id]=1,2,3`, `search[id]=<42`, `search[id]=1..10`, for
  example, are all accepted.
2017-12-17 17:36:52 -06:00
evazion
002b5e385a Autoban dmail spambots (#3408).
If a user sends spam to more than 10 users within a 24 hour window,
automatically ban them for 3 days.
2017-12-15 19:14:27 -06:00
evazion
e2eb45a5a3 Auto-promote DanbooruBot to Mod. Auto-create DanbooruBot if it doesn't exist. 2017-12-15 18:54:18 -06:00
evazion
b48211cd4a dmails: only spam check recipient's copy of the dmail.
Each dmail creates two copies, one for the sender and one for the
receiver. Only spam check the receiver's copy.

Prevents senders from being able to tell when their messages are being
spam filtered.
2017-12-15 18:54:18 -06:00
evazion
127e4e385b Fix dmail failures when akismet isn't configured. 2017-11-25 21:46:32 -06:00
r888888888
1e413362e3 don't run spam checks on gold account users (ref #3301) 2017-09-15 16:15:32 -07:00
r888888888
b944b642b8 akismet integration 2017-09-14 13:37:36 -07:00
evazion
c1834ab8dd Inherit models from ApplicationRecord instead of ActiveRecord::Base. 2017-06-16 13:28:31 -05:00
evazion
3f760069b3 dmails: fix case sensitivity bug in dmail title search. 2017-05-21 13:52:56 -05:00
evazion
d1216f260e dmails: add search[title_matches] param. 2017-04-29 11:50:25 -05: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
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
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
r888888888
e80096bf19 fixes #2850: NoMethodError exception when sending DMail 2017-01-20 12:37:43 -08:00
Albert Yi
bfa1ac63a4 fixes #2677: secure way of sharing dmails 2016-12-05 16:28:05 -08:00
Albert Yi
79842f7a3b restrict min level constraints for forum topics to mod+admin and restrict options based on current user's level. check privileges for visiblity in forum posts and topics. deprecate serializable_hash (undocumented, internal) for as_json, refactor to use hidden_attributes and method_attributes #2658 2016-10-25 15:05:55 -07:00
Type-kun
a718560554 Initial support for #2677 2016-09-17 16:42:00 +05:00
r888888888
3df9f0cdf6 fix unit tests 2015-09-23 12:13:14 -07:00
r888888888
341b29ce41 fix tests 2015-08-18 17:40:53 -07:00
r888888888
b31c63b261 fixes #2477: Better way to notify when messages get filtered 2015-08-13 17:16:24 -07:00
Toks
42ad3b8d3c #2326 fix has_mail being set by wrong copy 2014-12-12 23:59:26 -05:00
r888888888
cee524ec48 fixes #2326 2014-12-12 17:36:48 -08:00
r888888888
2b5ce48d5c fixes #2230 2014-11-19 21:28:26 -08:00
r888888888
f65691b5e6 fix tests 2014-06-18 16:51:55 -07:00
r888888888
fad0ab7c93 fixes #2133 2014-04-16 17:43:34 -07:00
Toks
421adfc65c Add unread dmail search option 2014-03-29 16:28:55 -04:00
Toks
3f869e8582 Fix case where user's has_mail could be erroneously set to false 2014-03-26 16:48:53 -04:00
r888888888
d58a150756 potential fix for #1428 2014-03-06 18:56:51 -08:00
r888888888
10516c9834 fixes #2100 2014-02-21 13:46:45 -08:00
Toks
adbe269aea fixes #1507 2013-08-27 00:39:07 -04:00
Toks
d527f822f2 fixes #1917 2013-08-07 20:25:51 -04:00
Toks
ecfcebe30a Add support for wildcard searches in text fields
#1663
2013-07-20 16:51:55 -04:00
Toks
395f3d1342 hide index fields from api; closes #1739 2013-06-23 12:12:30 -04:00
albert
85a5fcc658 fixes #1133 2013-03-29 16:45:59 -04:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
2338f004eb refactored tsquery sql to use rails escaping mechanisms 2013-03-07 16:34:12 -05:00
albert
dba5fd23e1 fixes #778 2013-03-06 20:13:55 -05:00