diff --git a/enterprise/app/controllers/api/v1/accounts/captain/documents_controller.rb b/enterprise/app/controllers/api/v1/accounts/captain/documents_controller.rb index 9743c3892..67730db57 100644 --- a/enterprise/app/controllers/api/v1/accounts/captain/documents_controller.rb +++ b/enterprise/app/controllers/api/v1/accounts/captain/documents_controller.rb @@ -3,6 +3,7 @@ class Api::V1::Accounts::Captain::DocumentsController < Api::V1::Accounts::BaseC before_action -> { check_authorization(Captain::Assistant) } before_action :set_current_page, only: [:index] + before_action :ensure_within_plan_limit, only: [:create] before_action :set_documents, except: [:create] before_action :set_document, only: [:show, :destroy] before_action :set_assistant, only: [:create] @@ -48,6 +49,10 @@ class Api::V1::Accounts::Captain::DocumentsController < Api::V1::Accounts::BaseC @current_page = permitted_params[:page] || 1 end + def ensure_within_plan_limit + Current.account.account.usage_limits[:captain][:documents][:current_available].positive? + end + def permitted_params params.permit(:assistant_id, :page, :id, :account_id) end