Explicit ES import when AP status or account is created or updated

This commit is contained in:
Vyr Cossont 2022-12-18 16:21:32 -08:00
parent 98c9bc52c0
commit 87b5f7f485
5 changed files with 9 additions and 2 deletions

View file

@ -85,6 +85,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
attach_tags(@status)
end
StatusesIndex.import! @status
resolve_thread(@status)
fetch_replies(@status)
distribute

View file

@ -25,7 +25,8 @@ class Importer::StatusesIndexImporter < Importer::BaseImporter
# on the results of the filter, so this filtering happens here instead
bulk.map! do |entry|
new_entry = begin
if entry[:index] && entry.dig(:index, :data, 'searchable_by').blank?
if entry[:index] && entry.dig(:index, :data, 'searchable_by').blank? &&
Rails.configuration.x.search_scope == :classic
{ delete: entry[:index].except(:data) }
else
entry

View file

@ -73,6 +73,8 @@ class ActivityPub::ProcessAccountService < BaseService
set_fetchable_attributes! unless @options[:only_key] || @account.suspended?
@account.save_with_optional_media!
AccountsIndex.import! @account
end
def set_immediate_protocol_attributes!

View file

@ -50,6 +50,8 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
reset_preview_card!
broadcast_updates!
StatusesIndex.import! @status
end
forward_activity! if significant_changes? && @status_parser.edited_at > last_edit_date

View file

@ -40,7 +40,7 @@ class SearchService < BaseService
when :public
statuses_index = statuses_index.filter.or(term: { visibility: 'public' })
when :public_or_unlisted
statuses_index = statuses_index.filter.or(term: { visibility: ['public', 'unlisted'] })
statuses_index = statuses_index.filter.or(terms: { visibility: ['public', 'unlisted'] })
end
definition = parsed_query.apply(statuses_index)