Commit Graph

51 Commits

Author SHA1 Message Date
evazion
480f39c34a pundit: convert dmails to pundit. 2020-03-20 18:03:01 -05:00
evazion
dc1742321d dmails: send email notifications in background job. 2020-03-14 21:06:29 -05:00
evazion
258f4a8b95 users: move emails to separate table.
* Move emails from users table to email_addresses table.
* Validate that addresses are formatted correctly and are unique across
  users. Existing invalid emails are grandfathered in.
* Add is_verified flag (the address has been confirmed by the user).
* Add is_deliverable flag (an undeliverable address is an address that bounces).
* Normalize addresses to prevent registering multiple accounts with the
  same email address (using tricks like Gmail's plus addressing).
2020-03-12 21:18:53 -05:00
evazion
3a018ee9f7 dmails: set sender name and ip address explicitly.
Set the sender name and IP addresses explicitly in the controller rather
than implicitly in the model.

Fixes cases where automated dmails from DanbooruBot had their IP
addresses set to the person who triggered the dmail, even though they
didn't actually send the dmail themselves.
2020-02-23 17:26:08 -06:00
evazion
bb2022abed mod reports: autoreport spam and autoban spammers.
* Automatically generate a mod report when a comment, forum post, or
  dmail is detected as spam.
* Automatically ban users that receive too many automatic spam reports
  within a short window of time.
* Automatically mark spam dmails as deleted.
* Change ban threshold from 10 spam reports in 24 hours to 10 reports in 1 hour.
* Change ban length from 3 days to forever.
2020-02-03 04:52:12 -06:00
evazion
6468df6d44 dmails: allow marking dmails as unread.
* Add ability to mark dmails as unread.
* Fix users.unread_dmail_count to not count deleted dmails.
* Fix show action so that API calls don't mark dmails as read.
* Don't show the unread dmail notice on the /dmails page itself.
* Stop using users.has_mail flag.
2020-02-01 15:49:33 -06:00
evazion
cae9a5d7e3 Drop dmail filters.
Few people used dmail filters (~900 users in 5 years) and even fewer
used them correctly. Most people used them to try to block dmail spam,
but usually they either blocked too much (by adding common words that
are present in nearly all dmails, causing all mails to them to be
filtered) or too little (blocking specific email addresses or urls,
which usually are never seen again after the spammer is banned).
Nowadays the spam detection system does a better job of filtering spam.
2020-01-21 00:10:20 -06:00
evazion
309821bf73 rubocop: fix various style issues. 2019-12-22 21:23:37 -06:00
evazion
06d0ceb016 dmails: fix bug with parsing wiki links in email notifications.
Bug: sending a dmail containing a wiki link (ex: [[tagme]]) failed when
the recipient had email notifications turned on.

Cause: wiki links inside email notifications use absolute urls, which
the dtext postprocessor didn't parse correctly.
2019-11-05 19:10:41 -06:00
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
06ff249530 dmails: factor out spam detector service. 2019-08-23 22:38:03 -05:00
evazion
6ba3d68792 dmails: fix feedback not being left when spammer is autobanned. 2019-08-22 21:29:58 -05:00
evazion
d05ebfe116 dmails: fix bug preventing members from sending dmails.
Bug: sending dmails failed for members.

Cause: using lambdas with `rakismet_attrs` failed because unexpected
arguments are passed to the lambdas. Using procs works because the
arguments are ignored.

Also fix the tests to actually test akismet. We didn't catch this
because the tests mocked out the `spam?` call.
2019-08-22 00:42:49 -05:00
evazion
f5c9616f62 tests: fix broken tests. 2018-09-24 17:34:08 -05:00
evazion
03abbd0683 Fix #2894: Use [[:space:]] instead of \s in regexes. 2018-09-20 19:24:38 -05:00
evazion
0eff095a3e Refactor searching text attributes.
* Allow using ApplicationRecord#attribute_matches to search text attributes,
and standardize models on using this instead of duplicating code.

* Remove restrictions that limited wildcard searches to Builders only in various places.
2018-08-31 19:50:46 -05: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
r888888888
4a80d6c337 refactor User#validate_sock_puppet to disable for tests 2018-01-02 14:32:38 -08:00
evazion
1ca2497015 Fix #3474: Spurious email notifications. 2017-12-28 18:50:08 -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
r888888888
502f1298a9 fix unit tests 2017-11-20 16:30:07 -08:00
r888888888
b944b642b8 akismet integration 2017-09-14 13:37:36 -07:00
evazion
3f760069b3 dmails: fix case sensitivity bug in dmail title search. 2017-05-21 13:52:56 -05:00
evazion
e31f8acc34 dmails: add title search test. 2017-04-29 11:50:26 -05:00
evazion
c0e5c400a7 tests: fix tests for Rails.cache. 2017-04-16 16:48:36 -05: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
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
47f663e002 Don't filter dmails from moderators (fix #2757). 2016-11-12 01:11:40 -06:00
r888888888
b31c63b261 fixes #2477: Better way to notify when messages get filtered 2015-08-13 17:16:24 -07:00
r888888888
6233bfd40e fix tests 2015-02-10 18:37:23 -08:00
r888888888
cee524ec48 fixes #2326 2014-12-12 17:36:48 -08:00
r888888888
ad22e42e62 fixes #2325 2014-12-12 17:32:33 -08:00
r888888888
02c07fefb2 fix tests 2014-12-03 14:07:42 -08:00
r888888888
2b5ce48d5c fixes #2230 2014-11-19 21:28:26 -08:00
r888888888
594b09b8c9 fix dmail tests 2014-03-26 16:01:10 -07:00
Toks
d8fd5fb212 fix dmail test 2013-08-27 23:21:28 -04:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
dba5fd23e1 fixes #778 2013-03-06 20:13:55 -05:00
albert
68ac05e31c fixes #705 2013-03-02 22:45:15 -05:00
albert
17881068e1 * Removed Pixa/Tinami sources
* Upgraded to Rails 3.2.3
* Fixed tests
2012-06-01 19:22:58 -04:00
albert
0887c35922 fixed unit tests 2012-01-15 14:40:36 -05:00
Dean Matzkov
5efb6a5b92 Fix unit tests for ruby-1.8 compatibility 2011-09-08 21:00:29 -06:00
albert
668fbab77a * Updated gemfile
* Added forum post/topic unit tests
* Added forum post/topic controller tests
2011-01-12 18:00:07 -05:00
albert
46164eab4f finished dmails and favorites functional tests 2010-12-05 22:27:45 -05:00
albert
f8ab736677 fixed tests 2010-11-19 17:20:13 -05:00
albert
c6304c6e08 views 2010-11-19 16:24:17 -05:00
albert
ad39553aac updated tests, switched to rails 3.0.0rc2 2010-08-26 14:36:02 -04:00