Skip to content

Commit

Permalink
some anti-spam measures
Browse files Browse the repository at this point in the history
  • Loading branch information
drusepth committed Mar 27, 2024
1 parent cfce459 commit 5ae70be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def set_user
@user = User.find_by(user_params)
return redirect_to(root_path, notice: 'That user does not exist.') if @user.nil?
return redirect_to(root_path, notice: 'That user has chosen to hide their profile.') if @user.private_profile?
return redirect_to(root_path, notice: 'That user has had their profile hidden.') if @user.thredded_user_detail.moderation_state == 'blocked'

@accent_color = @user.favorite_page_type_color
@accent_icon = @user.favorite_page_type_icon
Expand Down
2 changes: 1 addition & 1 deletion app/models/stream/share_comment.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ShareComment < ApplicationRecord
acts_as_paranoid

belongs_to :user, optional: true
belongs_to :user, optional: true # now that we're auto-deleting this data, we can probably remove this constraint without db errors
belongs_to :content_page_share

def from_op?(share)
Expand Down
6 changes: 6 additions & 0 deletions lib/tasks/daily.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ namespace :daily do
task clear_thredded_spam: :environment do
Thredded::Post.where(moderation_state: "blocked").destroy_all
Thredded::Topic.where(moderation_state: "blocked").destroy_all

blocked_user_ids = Thredded::UserDetail.where(moderation_state: "blocked").pluck(:user_id)

# Destroy all stream comments from blocked users and nil users
ShareComment.where(user_id: blocked_user_ids).destroy_all
ShareComment.where(user_id: nil).destroy_all
end

desc "Run end-of-day-analytics reporter"
Expand Down

0 comments on commit 5ae70be

Please sign in to comment.