about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-10-09 14:48:43 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-10-09 14:48:59 +0200
commit22a8801dbc77d2d01b326a7cb89d1a28b054e073 (patch)
tree11a3a99e98df33cbb73da818419fa0227b1dc664 /app/models
parent52d7f862d365acfd4eacbe448238699d9662708d (diff)
Adding domain blocks
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account.rb8
-rw-r--r--app/models/domain_block.rb7
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