Add requested_deletion_at attribute to Account for deleted-but-not-suspended accounts (#23617)

This commit is contained in:
Claire authored and GitHub committed 2026-07-31 13:55:33 +00:00
1 parent 1ea3bbcce8
commit ad245adf51
63 files changed
+757 -120

No files matched your search

@@ -0,0 +1,9 @@
# frozen_string_literal: true
class Api::V1::Accounts::BaseController < Api::BaseController
private
def set_account
@account = Account.without_requested_deletion.find(params[:account_id])
end
end
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class Api::V1::Accounts::EndorsementsController < Api::BaseController
class Api::V1::Accounts::EndorsementsController < Api::V1::Accounts::BaseController
include Authorization
before_action -> { authorize_if_got_token! :read, :'read:accounts' }, only: :index
@@ -28,10 +28,6 @@ class Api::V1::Accounts::EndorsementsController < Api::BaseController
private
def set_account
@account = Account.find(params[:account_id])
end
def set_endorsed_accounts
@endorsed_accounts = @account.unavailable? ? [] : paginated_endorsed_accounts
end
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class Api::V1::Accounts::FeaturedTagsController < Api::BaseController
class Api::V1::Accounts::FeaturedTagsController < Api::V1::Accounts::BaseController
before_action :set_account
before_action :set_featured_tags
@@ -12,10 +12,6 @@ class Api::V1::Accounts::FeaturedTagsController < Api::BaseController
private
def set_account
@account = Account.find(params[:account_id])
end
def set_featured_tags
@featured_tags = @account.unavailable? ? [] : @account.featured_tags
end
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class Api::V1::Accounts::FollowerAccountsController < Api::BaseController
class Api::V1::Accounts::FollowerAccountsController < Api::V1::Accounts::BaseController
before_action -> { authorize_if_got_token! :read, :'read:accounts' }
before_action :set_account
after_action :insert_pagination_headers
@@ -13,10 +13,6 @@ class Api::V1::Accounts::FollowerAccountsController < Api::BaseController
private
def set_account
@account = Account.find(params[:account_id])
end
def load_accounts
return [] if hide_results?
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class Api::V1::Accounts::FollowingAccountsController < Api::BaseController
class Api::V1::Accounts::FollowingAccountsController < Api::V1::Accounts::BaseController
before_action -> { authorize_if_got_token! :read, :'read:accounts' }
before_action :set_account
after_action :insert_pagination_headers
@@ -13,10 +13,6 @@ class Api::V1::Accounts::FollowingAccountsController < Api::BaseController
private
def set_account
@account = Account.find(params[:account_id])
end
def load_accounts
return [] if hide_results?
@@ -6,15 +6,8 @@ class Api::V1::Accounts::IdentityProofsController < Api::BaseController
deprecate_api '2022-03-30'
before_action :require_user!
before_action :set_account
def index
render json: []
end
private
def set_account
@account = Account.find(params[:account_id])
end
end
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class Api::V1::Accounts::ListsController < Api::BaseController
class Api::V1::Accounts::ListsController < Api::V1::Accounts::BaseController
before_action -> { doorkeeper_authorize! :read, :'read:lists' }
before_action :require_user!
before_action :set_account
@@ -9,10 +9,4 @@ class Api::V1::Accounts::ListsController < Api::BaseController
@lists = @account.suspended? ? [] : @account.lists.where(account: current_account)
render json: @lists, each_serializer: REST::ListSerializer
end
private
def set_account
@account = Account.find(params[:account_id])
end
end
@@ -13,6 +13,7 @@ class Api::V1::Accounts::LookupController < Api::BaseController
def set_account
@account = ResolveAccountService.new.call(params[:acct], skip_webfinger: true) || raise(ActiveRecord::RecordNotFound)
raise ActiveRecord::RecordNotFound if @account.deleted?
rescue Addressable::URI::InvalidURIError
raise(ActiveRecord::RecordNotFound)
end
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class Api::V1::Accounts::NotesController < Api::BaseController
class Api::V1::Accounts::NotesController < Api::V1::Accounts::BaseController
include Authorization
before_action -> { doorkeeper_authorize! :write, :'write:accounts' }
@@ -20,10 +20,6 @@ class Api::V1::Accounts::NotesController < Api::BaseController
private
def set_account
@account = Account.find(params[:account_id])
end
def relationships_presenter
AccountRelationshipsPresenter.new([@account], current_user.account_id)
end
@@ -5,7 +5,7 @@ class Api::V1::Accounts::RelationshipsController < Api::BaseController
before_action :require_user!
def index
@accounts = Account.where(id: account_ids).select(:id, :domain)
@accounts = Account.without_requested_deletion.where(id: account_ids).select(:id, :domain)
@accounts.merge!(Account.without_suspended) unless truthy_param?(:with_suspended)
render json: @accounts, each_serializer: REST::RelationshipSerializer, relationships: relationships
end
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class Api::V1::Accounts::StatusesController < Api::BaseController
class Api::V1::Accounts::StatusesController < Api::V1::Accounts::BaseController
before_action -> { authorize_if_got_token! :read, :'read:statuses' }
before_action :set_account
@@ -14,10 +14,6 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
private
def set_account
@account = Account.find(params[:account_id])
end
def load_statuses
@account.unavailable? ? [] : preloaded_account_statuses
end
@@ -84,7 +84,7 @@ class Api::V1::AccountsController < Api::BaseController
private
def set_account
@account = Account.find(params[:id])
@account = Account.without_requested_deletion.find(params[:id])
end
def set_accounts
@@ -50,7 +50,7 @@ class Api::V1::CollectionItemsController < Api::BaseController
def set_account
return render(json: { error: '`account_id` parameter is missing' }, status: 422) if params[:account_id].blank?
@account = Account.find(params[:account_id])
@account = Account.without_requested_deletion.find(params[:account_id])
end
def set_collection_item
@@ -69,7 +69,7 @@ class Api::V1::CollectionsController < Api::BaseController
private
def set_account
@account = Account.find(params[:account_id])
@account = Account.without_requested_deletion.find(params[:account_id])
end
def set_collections
@@ -25,7 +25,7 @@ class Api::V1::InCollectionsController < Api::BaseController
private
def set_account
@account = Account.find(params[:account_id])
@account = Account.without_requested_deletion.find(params[:account_id])
end
def set_collections