mirror of
https://github.com/mastodon/mastodon.git
synced 2025-02-07 01:39:20 +01:00
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.
46 lines
1.3 KiB
Ruby
46 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Status::FaspConcern
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
after_commit :announce_new_content_to_subscribed_fasp, on: :create
|
|
after_commit :announce_updated_content_to_subscribed_fasp, on: :update
|
|
after_commit :announce_deleted_content_to_subscribed_fasp, on: :destroy
|
|
after_commit :announce_trends_to_subscribed_fasp, on: :create
|
|
end
|
|
|
|
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']
|
|
elsif in_reply_to_id
|
|
[in_reply_to_id, 'reply']
|
|
end
|
|
Fasp::AnnounceTrendWorker.perform_async(candidate_id, trend_source) if candidate_id
|
|
end
|
|
end
|