mirror of https://github.com/mastodon/mastodon
Send searches to FASP...
...to backfill accounts that might be missing. Sadly, this has no effect on the search performed, but has the potential to improvde future searches.feat/fasp_account_search
parent
103475edc1
commit
c83ff20d12
@ -0,0 +1,25 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Fasp::AccountSearchWorker
|
||||||
|
include Sidekiq::Worker
|
||||||
|
|
||||||
|
sidekiq_options queue: 'fasp', retry: 0
|
||||||
|
|
||||||
|
def perform(query)
|
||||||
|
return unless Mastodon::Feature.fasp_enabled?
|
||||||
|
|
||||||
|
account_search_providers = Fasp::Provider.with_capability('account_search')
|
||||||
|
return if account_search_providers.none?
|
||||||
|
|
||||||
|
params = { term: query, limit: 10 }.to_query
|
||||||
|
fetch_service = ActivityPub::FetchRemoteActorService.new
|
||||||
|
|
||||||
|
account_search_providers.each do |provider|
|
||||||
|
Fasp::Request.new(provider).get("/account_search/v0/search?#{params}").each do |uri|
|
||||||
|
next if Account.where(uri:).any?
|
||||||
|
|
||||||
|
fetch_service.call(uri)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue