Add simple API to remove item from collection (#37225)

This commit is contained in:
David Roetzel
2025-12-15 09:03:49 +01:00
committed by GitHub
parent 372de345d7
commit bb72ecd466
3 changed files with 63 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ class Api::V1Alpha::CollectionItemsController < Api::BaseController
before_action :set_collection
before_action :set_account, only: [:create]
before_action :set_collection_item, only: [:destroy]
after_action :verify_authorized
@@ -23,6 +24,14 @@ class Api::V1Alpha::CollectionItemsController < Api::BaseController
render json: @item, serializer: REST::CollectionItemSerializer
end
def destroy
authorize @collection, :update?
@collection_item.destroy
head 200
end
private
def set_collection
@@ -35,6 +44,10 @@ class Api::V1Alpha::CollectionItemsController < Api::BaseController
@account = Account.find(params[:account_id])
end
def set_collection_item
@collection_item = @collection.collection_items.find(params[:id])
end
def check_feature_enabled
raise ActionController::RoutingError unless Mastodon::Feature.collections_enabled?
end