Fix anonymous block model associations

This commit is contained in:
Andreas Nedbal 2024-01-14 13:14:04 +01:00 committed by Andreas Nedbal
parent de9c84085d
commit 8b55b2fe81
2 changed files with 6 additions and 1 deletions

View File

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

View File

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