From 53ef8522f22feaeb0dfc52e7e87cc7e57cbec873 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Mon, 20 Jan 2025 15:54:39 +0530 Subject: [PATCH] feat: don't allow more documents than permitted --- .../api/v1/accounts/captain/documents_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) 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