Select what to share with fasp

Only share statuses where the account has `#indexable` set
to `true`.

Only share accounts where `#discoverable` is set to `true`, with
one exception: If `#discoverable` has just been set to `false`
this is an important information for the fasp.
This commit is contained in:
David Roetzel 2024-12-19 14:03:30 +01:00
parent d132bc6fa1
commit e01429d255
No known key found for this signature in database
4 changed files with 18 additions and 2 deletions

View File

@ -12,16 +12,22 @@ module Account::FaspConcern
private
def announce_new_account_to_subscribed_fasp
return unless discoverable?
uri = ActivityPub::TagManager.instance.uri_for(self)
Fasp::AnnounceAccountLifecycleEventWorker.perform_async(uri, 'new')
end
def announce_updated_account_to_subscribed_fasp
return unless discoverable? || saved_change_to_discoverable?
uri = ActivityPub::TagManager.instance.uri_for(self)
Fasp::AnnounceAccountLifecycleEventWorker.perform_async(uri, 'update')
end
def announce_deleted_account_to_subscribed_fasp
return unless discoverable?
uri = ActivityPub::TagManager.instance.uri_for(self)
Fasp::AnnounceAccountLifecycleEventWorker.perform_async(uri, 'delete')
end

View File

@ -13,19 +13,27 @@ module Status::FaspConcern
private
def announce_new_content_to_subscribed_fasp
return unless account_indexable?
store_uri unless uri # TODO: solve this more elegantly
Fasp::AnnounceContentLifecycleEventWorker.perform_async(uri, 'new')
end
def announce_updated_content_to_subscribed_fasp
return unless account_indexable?
Fasp::AnnounceContentLifecycleEventWorker.perform_async(uri, 'update')
end
def announce_deleted_content_to_subscribed_fasp
return unless account_indexable?
Fasp::AnnounceContentLifecycleEventWorker.perform_async(uri, 'delete')
end
def announce_trends_to_subscribed_fasp
return unless account_indexable?
candidate_id, trend_source =
if reblog_of_id
[reblog_of_id, 'reblog']

View File

@ -175,7 +175,7 @@ class Status < ApplicationRecord
],
thread: :account
delegate :domain, to: :account, prefix: true
delegate :domain, :indexable, to: :account, prefix: true
REAL_TIME_WINDOW = 6.hours

View File

@ -6,7 +6,9 @@ class Fasp::AnnounceTrendWorker
sidekiq_options queue: 'fasp', retry: 5
def perform(status_id, trend_source)
status = ::Status.find(status_id)
status = ::Status.includes(:account).find(status_id)
return unless status.account.indexable?
Fasp::Subscription.includes(:fasp_provider).content.trends.each do |subscription|
announce(subscription, status.uri) if trending?(subscription, status, trend_source)
end