diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/account.rb | 1 | ||||
-rw-r--r-- | app/models/collection_item.rb | 20 | ||||
-rw-r--r-- | app/models/collection_page.rb | 17 | ||||
-rw-r--r-- | app/models/concerns/account_associations.rb | 6 | ||||
-rw-r--r-- | app/models/follow_request.rb | 5 |
5 files changed, 48 insertions, 1 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index aad6dc728..c7bf7bf80 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -55,6 +55,7 @@ # show_unlisted :boolean default(TRUE), not null # private :boolean default(FALSE), not null # require_auth :boolean default(FALSE), not null +# last_synced_at :datetime # class Account < ApplicationRecord diff --git a/app/models/collection_item.rb b/app/models/collection_item.rb new file mode 100644 index 000000000..cecb86534 --- /dev/null +++ b/app/models/collection_item.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true +# == Schema Information +# +# Table name: collection_items +# +# id :bigint(8) not null, primary key +# account_id :bigint(8) +# uri :string not null +# processed :boolean default(FALSE), not null +# + +class CollectionItem < ApplicationRecord + belongs_to :account, inverse_of: :collection_items, optional: true + + default_scope { order(id: :desc) } + scope :unprocessed, -> { where(processed: false) } + scope :joins_on_collection_pages, -> { joins('LEFT OUTER JOIN collection_pages ON collection_pages.account_id = collection_items.account_id') } + scope :inactive, -> { joins_on_collection_pages.where('collection_pages.account_id IS NULL') } + scope :active, -> { joins_on_collection_pages.where('collection_pages.account_id IS NOT NULL') } +end diff --git a/app/models/collection_page.rb b/app/models/collection_page.rb new file mode 100644 index 000000000..e974e58a2 --- /dev/null +++ b/app/models/collection_page.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true +# == Schema Information +# +# Table name: collection_pages +# +# id :bigint(8) not null, primary key +# account_id :bigint(8) +# uri :string not null +# next :string +# + +class CollectionPage < ApplicationRecord + belongs_to :account, inverse_of: :collection_pages, optional: true + + default_scope { order(id: :desc) } + scope :current, -> { where(next: nil) } +end diff --git a/app/models/concerns/account_associations.rb b/app/models/concerns/account_associations.rb index 14f64cb71..eff470ffa 100644 --- a/app/models/concerns/account_associations.rb +++ b/app/models/concerns/account_associations.rb @@ -78,5 +78,11 @@ module AccountAssociations # Queued boosts has_many :queued_boosts, inverse_of: :account, dependent: :destroy + + # Collection pages + has_many :collection_pages, inverse_of: :account, dependent: :destroy + + # Collection items + has_many :collection_items, inverse_of: :account, dependent: :destroy end end diff --git a/app/models/follow_request.rb b/app/models/follow_request.rb index 3325e264c..cdf0f4bda 100644 --- a/app/models/follow_request.rb +++ b/app/models/follow_request.rb @@ -29,7 +29,10 @@ class FollowRequest < ApplicationRecord def authorize! account.follow!(target_account, reblogs: show_reblogs, uri: uri) - MergeWorker.perform_async(target_account.id, account.id) if account.local? + if account.local? + MergeWorker.perform_async(target_account.id, account.id) + ActivityPub::SyncAccountWorker.perform_async(target_account.id, every_page: true) unless target_account.local? + end destroy! end |