Commit Graph

69 Commits

Author SHA1 Message Date
evazion
0df5c0fd2b Replace deprecated update_attributes with update.
https://rubyinrails.com/2019/04/09/rails-6-1-activerecord-deprecates-update-attributes-methods/

DEPRECATION WARNING: update_attributes! is deprecated and will be removed from Rails 6.1 (please, use update! instead)
2019-08-25 20:29:32 -05:00
evazion
59b277ead1 users: drop id_to_name, name_to_id caching.
Changes:

* Drop Users.id_to_name.
* Don't cache Users.name_to_id.
* Replace calls to name_to_id with find_by_name when possible.
* Don't autodefine creator_name in belongs_to_creator.
* Don't autodefine updater_name in belongs_to_updater.
* Instead manually define creator_name / updater_name only on models that need
  to return these fields in the api.

id_to_name was cached to reduce the impact of N+1 query patterns in
certain places, especially in api responses that return creator_name /
updater_name fields. But it still meant we were doing N calls to
memcache. Using `includes` to prefetch users avoids this N+1 pattern.

name_to_id had no need be cached, it was never used in any performance-
sensitive contexts.

Avoiding caching also avoids the need to keep these caches consistent.
2019-08-18 11:24:42 -05:00
evazion
7871dced00 users: fix find_by_name, name_to_id to strip whitespace.
Fix find_by_name and name_to_id to use normalize_name properly, so that
they ignore leading/trailing whitespace. This fixes various search forms
failing to return results when the username field contains trailing
whitespace (inserted by autocomplete).
2019-08-18 11:24:42 -05:00
evazion
82fbb19e0f users: drop unused code. 2019-08-18 11:24:42 -05:00
evazion
a71899559a tests: fix ip ban test regression. 2019-08-12 14:17:00 -05:00
evazion
f5012464ab Fix #3965: Extraneous API attributes.
Remove the updater_id/updater_ip_addr virtual attributes from
pools/notes. Juss pass them in as params to create_version instead.
2018-10-30 15:41:17 -05:00
evazion
3dafca9aec Fix #3842: Mods can demote other mods or admins. 2018-08-25 13:52:50 -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
BrokenEagle
dd8d80eaf7 Updated tests for mod actions 2018-01-14 00:07:20 -08:00
r888888888
604e9e9866 fix some unit tests 2018-01-02 15:12:48 -08:00
evazion
e2eb45a5a3 Auto-promote DanbooruBot to Mod. Auto-create DanbooruBot if it doesn't exist. 2017-12-15 18:54:18 -06:00
r888888888
4c565b443e add 24 hour window for repeating an ip addr for account creation (ref #3301) 2017-09-15 15:13:01 -07:00
evazion
5a6cc84817 favorites: don't regen fav count when adding favorites.
Don't randomly regen the fav count when favoriting a post. This was a
workaround for #1210 that is no longer needed.
2017-09-13 13:29:35 -07:00
evazion
cebf29f83e Allow escaping wildcards (\*) in wildcard searches. 2017-05-31 16:15:18 -05:00
r888888888
48e9856f37 fixes #3007: Eliminate Janitor role 2017-05-01 14:38:30 -07:00
evazion
c0e5c400a7 tests: fix tests for Rails.cache. 2017-04-16 16:48:36 -05:00
Albert Yi
fd7cddc909 Merge branch 'master' into fix-mention-dmails 2017-02-27 17:00:24 -08: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
6966b74e18 Disallow unicode whitespace in usernames (#2894). 2017-02-25 01:51:33 -06:00
evazion
6704e71377 dmails: add tests for automated dmails. 2017-02-23 22:51:17 -06:00
Albert Yi
5a1ac41450 eliminate transaction log items table 2016-12-21 15:00:59 -08:00
evazion
01afc46f74 Fix failures in commenting tests.
Restricting users from upvoting their own comments broke some tests.
Switch these tests to downvoting instead.
2016-12-03 20:06:50 -06:00
r888888888
ce3af81c9f fix tests 2016-01-18 17:13:26 -08:00
r888888888
6480864718 fixes #2469 2015-10-15 15:24:24 -07:00
r888888888
3df9f0cdf6 fix unit tests 2015-09-23 12:13:14 -07:00
Toks
055d0eecd3 Remove redundant promoter name from user feedback
Feedbacks already keep track of who created them so it doesn't need to
be in the body too
2014-04-30 21:18:18 -04:00
r888888888
fad0ab7c93 fixes #2133 2014-04-16 17:43:34 -07:00
r888888888
37d75e4a88 Fixes #1266 2014-03-05 17:53:26 -08:00
r888888888
14dd0430cb fixes #1257 2014-03-05 17:33:57 -08:00
r888888888
a285089f7a potential fix for #1926 2014-02-13 11:30:35 -08:00
r888888888
e510e4d35f remove unused deletion code from user 2013-05-20 17:50:13 -07:00
r888888888
7db85d8301 Merge branch 'master' into close-accounts 2013-05-16 14:16:47 -07:00
Toks
6d0bac70f6 fix user promotion test 2013-05-02 22:30:42 -04:00
r888888888
51a62a8df6 add support for deleting user accounts 2013-04-29 22:47:08 -07:00
r888888888
d5f575159f rename references of privileged to gold 2013-04-28 00:04:52 -07:00
r888888888
e861425315 stopgap measure for #1210 2013-04-26 17:54:46 -07:00
r888888888
4320df3116 fixes #1372 2013-04-19 15:51:38 -07:00
albert
8653423d3b fix user test 2013-04-08 14:40:24 -04:00
albert
c540c4f891 Fixes #1121, rename Post#annihilate to Post#expunge 2013-04-08 13:44:43 -04:00
albert
b19994396d fix tests, fixes #1173 2013-04-03 17:23:25 -04:00
albert
a4b67fa072 fix tests and typo bugs 2013-03-22 18:54:37 -04:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
5ab9887923 only store partial hash in cookies for validation 2013-03-05 16:49:09 -05:00
albert
f52181db94 Major revamp of security. Passwords are first SHA1 hashed and then
that hash is bcrypted.  Bcrypted hashes are stored in a new column on
users.  This separate column is only to allow for rollbacks,
eventually the old SHA1 hash column will be removed.  Sensitive cookie
details are now encrypted to prevent user tampering and more stringent
checks on secret_token and session_secret_key are enforced.
2013-03-04 22:55:41 -05:00
albert
427e90bafb switch version to 2.1.0 2013-03-03 16:14:03 -05:00
albert
132ef8f93c hide approval mod actions, better logic for user promotion/demotion mod actions 2013-02-28 10:19:31 -08:00
albert
17881068e1 * Removed Pixa/Tinami sources
* Upgraded to Rails 3.2.3
* Fixed tests
2012-06-01 19:22:58 -04:00
albert
5e3b243b67 users with no negative feedback can now change their names 2011-12-20 16:18:35 -05:00
albert
8fffa9747f fix attr_accessible 2011-12-14 11:19:58 -05:00
albert
a7267cf00b fixed tests 2011-10-16 01:40:42 -04:00