fix(captain): scope FAQ suggestions to agent access

This commit is contained in:
aakashb95
2026-07-17 13:11:33 +05:30
parent f6d97c56b4
commit 64d2751c06
3 changed files with 16 additions and 2 deletions
@@ -1,6 +1,6 @@
class Api::V1::Accounts::Captain::FaqSuggestionsController < Api::V1::Accounts::BaseController
before_action :current_account
before_action :check_admin_authorization?
before_action -> { check_authorization(Captain::Assistant) }
before_action :set_suggestions
before_action :set_suggestion, except: [:index]
@@ -59,6 +59,12 @@ class Api::V1::Accounts::Captain::FaqSuggestionsController < Api::V1::Accounts::
def set_suggestions
@suggestions = Current.account.captain_faq_suggestions.includes(:assistant).ordered
return if Current.account_user.administrator?
accessible_suggestion_ids = Captain::FaqObservation
.where(conversation_id: accessible_conversations.select(:id))
.select(:faq_suggestion_id)
@suggestions = @suggestions.where(id: accessible_suggestion_ids)
end
def set_suggestion