Return empty array when requesting collections of an account that blocked you (#37591)
This commit is contained in:
parent
0a0e253614
commit
c5c70311d8
@ -26,9 +26,11 @@ class Api::V1Alpha::CollectionsController < Api::BaseController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
cache_if_unauthenticated!
|
cache_if_unauthenticated!
|
||||||
authorize Collection, :index?
|
authorize @account, :index_collections?
|
||||||
|
|
||||||
render json: @collections, each_serializer: REST::CollectionSerializer, adapter: :json
|
render json: @collections, each_serializer: REST::CollectionSerializer, adapter: :json
|
||||||
|
rescue Mastodon::NotPermittedError
|
||||||
|
render json: { collections: [] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|||||||
@ -81,6 +81,19 @@ RSpec.describe 'Api::V1Alpha::Collections', feature: :collections do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when the requesting user is blocked by the given account' do
|
||||||
|
before do
|
||||||
|
account.block!(user.account)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns an empty array' do
|
||||||
|
subject
|
||||||
|
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
expect(response.parsed_body[:collections]).to eq []
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET /api/v1_alpha/collections/:id' do
|
describe 'GET /api/v1_alpha/collections/:id' do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user