diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/account.rb | 8 | ||||
-rw-r--r-- | app/models/domain_block.rb | 7 |
2 files changed, 11 insertions, 4 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index 12e7be05d..e43d51b1c 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -24,10 +24,10 @@ class Account < ApplicationRecord validates :note, length: { maximum: 124 }, if: 'local?' # Timelines - has_many :stream_entries, inverse_of: :account - has_many :statuses, inverse_of: :account - has_many :favourites, inverse_of: :account - has_many :mentions, inverse_of: :account + has_many :stream_entries, inverse_of: :account, dependent: :destroy + has_many :statuses, inverse_of: :account, dependent: :destroy + has_many :favourites, inverse_of: :account, dependent: :destroy + has_many :mentions, inverse_of: :account, dependent: :destroy # Follow relations has_many :active_relationships, class_name: 'Follow', foreign_key: 'account_id', dependent: :destroy diff --git a/app/models/domain_block.rb b/app/models/domain_block.rb new file mode 100644 index 000000000..8f9eb1182 --- /dev/null +++ b/app/models/domain_block.rb @@ -0,0 +1,7 @@ +class DomainBlock < ApplicationRecord + validates :domain, presence: true, uniqueness: true + + def self.blocked?(domain) + where(domain: domain).exists? + end +end |