Merge commit 'c357a7f8d697ede4df4be74456b0497118c9d049' into glitch-soc/merge-upstream
This commit is contained in:
commit
2eec4da8fc
154 files changed
+1168
-826
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
class Admin::DistributeAnnouncementNotificationWorker
|
||||
include Sidekiq::IterableJob
|
||||
include BulkMailer
|
||||
include BulkMailingConcern
|
||||
|
||||
def build_enumerator(announcement_id, cursor:)
|
||||
@announcement = Announcement.find(announcement_id)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
class Admin::DistributeTermsOfServiceNotificationWorker
|
||||
include Sidekiq::IterableJob
|
||||
include BulkMailer
|
||||
include BulkMailingConcern
|
||||
|
||||
def build_enumerator(terms_of_service_id, cursor:)
|
||||
@terms_of_service = TermsOfService.find(terms_of_service_id)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module BulkMailer
|
||||
module BulkMailingConcern
|
||||
def push_bulk_mailer(mailer_class, mailer_method, args_array)
|
||||
raise ArgumentError, "No method #{mailer_method} on class #{mailer_class.name}" unless mailer_class.respond_to?(mailer_method)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# 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?
|
||||
|
||||
async_refresh = AsyncRefresh.new("fasp:account_search:#{Digest::MD5.base64digest(query)}")
|
||||
|
||||
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?
|
||||
|
||||
account = fetch_service.call(uri)
|
||||
async_refresh.increment_result_count(by: 1) if account.present?
|
||||
end
|
||||
end
|
||||
ensure
|
||||
async_refresh&.finish!
|
||||
end
|
||||
end
|
||||
@@ -23,10 +23,19 @@ class Fasp::FollowRecommendationWorker
|
||||
Fasp::Request.new(provider).get("/follow_recommendation/v0/accounts?#{params}").each do |uri|
|
||||
next if Account.where(uri:).any?
|
||||
|
||||
account = fetch_service.call(uri)
|
||||
async_refresh.increment_result_count(by: 1) if account.present?
|
||||
new_account = fetch_service.call(uri)
|
||||
|
||||
if new_account.present?
|
||||
Fasp::FollowRecommendation.find_or_create_by(requesting_account: account, recommended_account: new_account)
|
||||
async_refresh.increment_result_count(by: 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Invalidate follow recommendation cache so it does not
|
||||
# take up to 15 minutes for the new recommendations to
|
||||
# show up
|
||||
Rails.cache.delete("follow_recommendations/#{account.id}")
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
# Nothing to be done
|
||||
ensure
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Scheduler::Fasp::FollowRecommendationCleanupScheduler
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options retry: 0, lock: :until_executed, lock_ttl: 1.day.to_i
|
||||
|
||||
def perform
|
||||
return unless Mastodon::Feature.fasp_enabled?
|
||||
|
||||
Fasp::FollowRecommendation.outdated.delete_all
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user