You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow direct suspension without requiring flagging first (#4364)
## Summary
- Expand the user risk state machine to allow suspending users directly
from `not_reviewed`, `compliant`, and cross-flag states (e.g.,
`flagged_for_tos_violation` → `suspended_for_fraud`)
- Simplify callers that previously did flag-then-suspend:
`suspend_due_to_stripe_risk`, `Iffy::User::BanService`,
`SuspendUsersWorker`, and `SuspendAccountsWithPaymentAddressWorker`
- Flag events (`flag_for_fraud`, `flag_for_tos_violation`) are preserved
for graduated response — they're now optional, not eliminated
Closes#4290
## Test plan
- [ ] Verify direct suspension from `not_reviewed` and `compliant`
states works
- [ ] Verify cross-flag suspension (e.g., `flagged_for_tos_violation` →
`suspended_for_fraud`) works
- [ ] Verify existing flag-then-suspend paths still work
- [ ] Verify mass suspension via admin still works
- [ ] Verify cascade suspension of related accounts (same payment
address/fingerprint) still works
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
content: "Flagged for fraud automatically on #{Time.current.to_fs(:formatted_date_full_month)} because of usage of #{identifier_type}#{identifier_value} (from User##{suspended_user.id})"
content: "Suspended for fraud automatically on #{Time.current.to_fs(:formatted_date_full_month)} because of usage of #{identifier_type}#{identifier_value} (from User##{suspended_user.id})",
content="Suspended for a policy violation by #{author_name} on #{Time.current.to_fs(:formatted_date_full_month)} as part of mass suspension. Reason: #{reason}."
Copy file name to clipboardExpand all lines: spec/sidekiq/suspend_accounts_with_payment_address_worker_spec.rb
+5-7Lines changed: 5 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -13,12 +13,11 @@
13
13
described_class.new.perform(@user.id)
14
14
15
15
expect(@user_2.reload.suspended?).tobe(true)
16
-
expect(@user_2.comments.first.content).toeq("Flagged for fraud automatically on #{Time.current.to_fs(:formatted_date_full_month)} because of usage of payment address #{@user.payment_address} (from User##{@user.id})")
17
-
expect(@user_2.comments.last.content).toeq("Suspended for fraud automatically on #{Time.current.to_fs(:formatted_date_full_month)} because of usage of payment address #{@user.payment_address} (from User##{@user.id})")
16
+
expect(@user_2.comments.count).toeq(1)
17
+
expect(@user_2.comments.first.content).toeq("Suspended for fraud automatically on #{Time.current.to_fs(:formatted_date_full_month)} because of usage of payment address #{@user.payment_address} (from User##{@user.id})")
18
18
end
19
19
20
20
it"does not suspend already suspended users with same payment address"do
21
-
@user_2.flag_for_fraud!(author_name: "test")
22
21
@user_2.suspend_for_fraud!(author_name: "test")
23
22
initial_comment_count=@user_2.comments.count
24
23
@@ -46,11 +45,11 @@
46
45
expect(@user_3.reload.suspended?).tobe(false)
47
46
end
48
47
49
-
it"creates both flagged and suspended comments with fingerprint details"do
48
+
it"creates a suspended comment with fingerprint details"do
50
49
described_class.new.perform(@user.id)
51
50
52
-
expect(@user_2.reload.comments.first.content).toeq("Flagged for fraud automatically on #{Time.current.to_fs(:formatted_date_full_month)} because of usage of bank account fingerprint same_fingerprint_123 (from User##{@user.id})")
53
-
expect(@user_2.comments.last.content).toeq("Suspended for fraud automatically on #{Time.current.to_fs(:formatted_date_full_month)} because of usage of bank account fingerprint same_fingerprint_123 (from User##{@user.id})")
51
+
expect(@user_2.reload.comments.count).toeq(1)
52
+
expect(@user_2.comments.first.content).toeq("Suspended for fraud automatically on #{Time.current.to_fs(:formatted_date_full_month)} because of usage of bank account fingerprint same_fingerprint_123 (from User##{@user.id})")
expect(comments.first.content).toeq("Flagged for a policy violation by #{admin_user.name_or_username} on #{Time.current.to_fs(:formatted_date_full_month)}")
23
+
expect(comments.count).toeq(1)
24
+
expect(comments.first.content).toeq("Suspended for a policy violation by #{admin_user.name_or_username} on #{Time.current.to_fs(:formatted_date_full_month)} as part of mass suspension. Reason: #{reason}.\nAdditional notes: #{additional_notes}")
expect(comments.last.content).toeq("Suspended for a policy violation by #{admin_user.name_or_username} on #{Time.current.to_fs(:formatted_date_full_month)} as part of mass suspension. Reason: #{reason}.\nAdditional notes: #{additional_notes}")
0 commit comments