mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
Ensure conversation access honors permissions
This commit is contained in:
@@ -160,6 +160,7 @@ class Api::V1::Accounts::ConversationsController < Api::V1::Accounts::BaseContro
|
||||
|
||||
def conversation
|
||||
@conversation ||= Current.account.conversations.find_by!(display_id: params[:id])
|
||||
authorize @conversation
|
||||
authorize @conversation.inbox, :show?
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
class ConversationPolicy < ApplicationPolicy
|
||||
class Scope < ApplicationPolicy::Scope
|
||||
def resolve
|
||||
return scope if user.is_a?(AgentBot)
|
||||
return scope.none if account.blank?
|
||||
|
||||
conversations = scope.where(account_id: account.id)
|
||||
Conversations::PermissionFilterService.new(conversations, user, account).perform
|
||||
end
|
||||
end
|
||||
|
||||
def index?
|
||||
true
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user