diff --git a/app/models/question.rb b/app/models/question.rb index 0a6adec0..84f5faf6 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -2,6 +2,7 @@ class Question < ApplicationRecord include Question::AnswerMethods belongs_to :user, optional: true + has_many :anonymous_blocks, dependent: :nullify has_many :answers, dependent: :destroy has_many :inboxes, dependent: :destroy diff --git a/app/models/user.rb b/app/models/user.rb index eb401fcd..e91aeeb9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -40,7 +40,6 @@ class User < ApplicationRecord has_many :lists, dependent: :destroy_async has_many :list_memberships, class_name: "ListMember", dependent: :destroy_async has_many :mute_rules, dependent: :destroy_async - has_many :anonymous_blocks, dependent: :destroy_async has_many :subscriptions, dependent: :destroy_async has_many :totp_recovery_codes, dependent: :destroy_async @@ -54,6 +53,11 @@ class User < ApplicationRecord foreign_key: "banned_by_id", dependent: :nullify + has_many :anonymous_blocks, dependent: :destroy_async + has_many :passive_anonymous_blocks, class_name: "AnonymousBlock", + foreign_key: "target_user_id", + dependent: :nullify + SCREEN_NAME_REGEX = /\A[a-zA-Z0-9_]+\z/ WEBSITE_REGEX = /https?:\/\/([A-Za-z.-]+)\/?(?:.*)/i