diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-11-21 14:59:13 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-11-21 14:59:13 +0100 |
commit | e8c27767aab0bf6c26d28944268a78fb5ac5d4e0 (patch) | |
tree | 1bbb416eb7736a43dd94ef0b64545a198567f4c1 /app/models | |
parent | 954f344cf7cba40a9d6493d2a76f5637beee2e6a (diff) |
Remove orphaned notifications, add scopes param to app create API
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/account.rb | 1 | ||||
-rw-r--r-- | app/models/favourite.rb | 2 | ||||
-rw-r--r-- | app/models/follow.rb | 2 | ||||
-rw-r--r-- | app/models/mention.rb | 2 | ||||
-rw-r--r-- | app/models/status.rb | 2 |
5 files changed, 9 insertions, 0 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index 90434f975..16d654195 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -31,6 +31,7 @@ class Account < ApplicationRecord has_many :statuses, inverse_of: :account, dependent: :destroy has_many :favourites, inverse_of: :account, dependent: :destroy has_many :mentions, inverse_of: :account, dependent: :destroy + has_many :notifications, 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/favourite.rb b/app/models/favourite.rb index 0a4f60ecb..541ca0831 100644 --- a/app/models/favourite.rb +++ b/app/models/favourite.rb @@ -7,6 +7,8 @@ class Favourite < ApplicationRecord belongs_to :account, inverse_of: :favourites belongs_to :status, inverse_of: :favourites, touch: true + has_one :notification, as: :activity, dependent: :destroy + validates :status_id, uniqueness: { scope: :account_id } def verb diff --git a/app/models/follow.rb b/app/models/follow.rb index c918dabf2..cc5bceb75 100644 --- a/app/models/follow.rb +++ b/app/models/follow.rb @@ -7,6 +7,8 @@ class Follow < ApplicationRecord belongs_to :account belongs_to :target_account, class_name: 'Account' + has_one :notification, as: :activity, dependent: :destroy + validates :account, :target_account, presence: true validates :account_id, uniqueness: { scope: :target_account_id } diff --git a/app/models/mention.rb b/app/models/mention.rb index a3c8baf21..10a9cb1cd 100644 --- a/app/models/mention.rb +++ b/app/models/mention.rb @@ -4,6 +4,8 @@ class Mention < ApplicationRecord belongs_to :account, inverse_of: :mentions belongs_to :status + has_one :notification, as: :activity, dependent: :destroy + validates :account, :status, presence: true validates :account, uniqueness: { scope: :status } end diff --git a/app/models/status.rb b/app/models/status.rb index a5c3e19ba..1bf4b49c9 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -16,6 +16,8 @@ class Status < ApplicationRecord has_many :media_attachments, dependent: :destroy has_and_belongs_to_many :tags + has_one :notification, as: :activity, dependent: :destroy + validates :account, presence: true validates :uri, uniqueness: true, unless: 'local?' validates :text, presence: true, length: { maximum: 500 }, if: proc { |s| s.local? && !s.reblog? } |