Add preview of followers removed in domain block modal in web UI (#32032)
This commit is contained in:
parent
28c4eca0af
commit
3426ea2912
12 changed files with 274 additions and 108 deletions
27
app/controllers/api/v1/domain_blocks/previews_controller.rb
Normal file
27
app/controllers/api/v1/domain_blocks/previews_controller.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Api::V1::DomainBlocks::PreviewsController < Api::BaseController
|
||||
before_action -> { doorkeeper_authorize! :follow, :write, :'write:blocks' }
|
||||
before_action :require_user!
|
||||
before_action :set_domain
|
||||
before_action :set_domain_block_preview
|
||||
|
||||
def show
|
||||
render json: @domain_block_preview, serializer: REST::DomainBlockPreviewSerializer
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_domain
|
||||
@domain = TagManager.instance.normalize_domain(params[:domain])
|
||||
end
|
||||
|
||||
def set_domain_block_preview
|
||||
@domain_block_preview = with_read_replica do
|
||||
DomainBlockPreviewPresenter.new(
|
||||
following_count: current_account.following.where(domain: @domain).count,
|
||||
followers_count: current_account.followers.where(domain: @domain).count
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue