diff --git a/app/controllers/api/v1/apps_controller.rb b/app/controllers/api/v1/apps_controller.rb index d1db16cf2ae1771ed420b8039ea3e015f8b9e125..fb95928a8b9fbb4b53fa6241eaeea0735054a2f2 100644 --- a/app/controllers/api/v1/apps_controller.rb +++ b/app/controllers/api/v1/apps_controller.rb @@ -4,6 +4,6 @@ class Api::V1::AppsController < ApiController respond_to :json def create - @app = Doorkeeper::Application.create!(name: params[:client_name], redirect_uri: params[:redirect_uris]) + @app = Doorkeeper::Application.create!(name: params[:client_name], redirect_uri: params[:redirect_uris], scopes: params[:scopes]) end end diff --git a/app/models/account.rb b/app/models/account.rb index 90434f97517b561f766660f4c0dd23991d7b58d1..16d654195fb86c85d8ce931fecd4e5fca812568a 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 0a4f60ecb4ca04bee9b90ea76c9eb6cbd7922008..541ca08314bfe7c71a7f9a94385a9bdee6e56537 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 c918dabf235f61c6ec822b2bd2340b4af504b9f5..cc5bceb752a65f96eb5fa075bcb42e152825616c 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 a3c8baf21aa64b623bf3aa841f99c1ffdea7552f..10a9cb1cd1a39a564aa4f296f303893daf795632 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 a5c3e19ba7fe57ed7b4a705c1cd9de0710e01005..1bf4b49c9070cec7703655984ae116255810fcac 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? }