From 22a8801dbc77d2d01b326a7cb89d1a28b054e073 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 9 Oct 2016 14:48:43 +0200 Subject: Adding domain blocks --- app/models/account.rb | 8 ++++---- app/models/domain_block.rb | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 app/models/domain_block.rb (limited to 'app/models') 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 -- cgit