mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 03:27: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
|
def conversation
|
||||||
@conversation ||= Current.account.conversations.find_by!(display_id: params[:id])
|
@conversation ||= Current.account.conversations.find_by!(display_id: params[:id])
|
||||||
|
authorize @conversation
|
||||||
authorize @conversation.inbox, :show?
|
authorize @conversation.inbox, :show?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,14 @@
|
|||||||
class ConversationPolicy < ApplicationPolicy
|
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?
|
def index?
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user