Extract private methods in api/v1/instances/domain_blocks (#27844)
This commit is contained in:
parent
373aa95ddd
commit
1f8173ac5a
1 changed files with 13 additions and 1 deletions
|
@ -13,7 +13,7 @@ class Api::V1::Instances::DomainBlocksController < Api::V1::Instances::BaseContr
|
||||||
cache_if_unauthenticated!
|
cache_if_unauthenticated!
|
||||||
end
|
end
|
||||||
|
|
||||||
render json: @domain_blocks, each_serializer: REST::DomainBlockSerializer, with_comment: (Setting.show_domain_blocks_rationale == 'all' || (Setting.show_domain_blocks_rationale == 'users' && user_signed_in?))
|
render json: @domain_blocks, each_serializer: REST::DomainBlockSerializer, with_comment: show_rationale_in_response?
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -25,4 +25,16 @@ class Api::V1::Instances::DomainBlocksController < Api::V1::Instances::BaseContr
|
||||||
def set_domain_blocks
|
def set_domain_blocks
|
||||||
@domain_blocks = DomainBlock.with_user_facing_limitations.by_severity
|
@domain_blocks = DomainBlock.with_user_facing_limitations.by_severity
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show_rationale_in_response?
|
||||||
|
always_show_rationale? || show_rationale_for_user?
|
||||||
|
end
|
||||||
|
|
||||||
|
def always_show_rationale?
|
||||||
|
Setting.show_domain_blocks_rationale == 'all'
|
||||||
|
end
|
||||||
|
|
||||||
|
def show_rationale_for_user?
|
||||||
|
Setting.show_domain_blocks_rationale == 'users' && user_signed_in?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue