some anti-spam measures

This commit is contained in:
Andrew Brown 2024-03-27 14:15:53 -07:00
parent cfce4595b7
commit 5ae70beaeb
3 changed files with 8 additions and 1 deletions

View File

@ -98,6 +98,7 @@ class UsersController < ApplicationController
@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

View File

@ -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)

View File

@ -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"