Merge commit 'c644413f8a068490ddb8038441e5b59112e8294e' into glitch-soc/merge-upstream

This commit is contained in:
Claire
2025-06-16 20:08:52 +02:00
61 changed files with 694 additions and 308 deletions

View File

@@ -92,7 +92,7 @@ class Api::BaseController < ApplicationController
end
def disallow_unauthenticated_api_access?
ENV['DISALLOW_UNAUTHENTICATED_API_ACCESS'] == 'true' || Rails.configuration.x.limited_federation_mode
ENV['DISALLOW_UNAUTHENTICATED_API_ACCESS'] == 'true' || Rails.configuration.x.mastodon.limited_federation_mode
end
private

View File

@@ -2,11 +2,13 @@
class Api::V2::SuggestionsController < Api::BaseController
include Authorization
include AsyncRefreshesConcern
before_action -> { doorkeeper_authorize! :read, :'read:accounts' }, only: :index
before_action -> { doorkeeper_authorize! :write, :'write:accounts' }, except: :index
before_action :require_user!
before_action :set_suggestions
before_action :schedule_fasp_retrieval
def index
render json: @suggestions.get(limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:offset].to_i), each_serializer: REST::SuggestionSerializer
@@ -22,4 +24,18 @@ class Api::V2::SuggestionsController < Api::BaseController
def set_suggestions
@suggestions = AccountSuggestions.new(current_account)
end
def schedule_fasp_retrieval
return unless Mastodon::Feature.fasp_enabled?
# Do not schedule a new retrieval if the request is a follow-up
# to an earlier retrieval
return if request.headers['Mastodon-Async-Refresh-Id'].present?
refresh_key = "fasp:follow_recommendation:#{current_account.id}"
return if AsyncRefresh.new(refresh_key).running?
add_async_refresh_header(AsyncRefresh.create(refresh_key))
Fasp::FollowRecommendationWorker.perform_async(current_account.id)
end
end