mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
Earlier, we were manually checking if a user was an agent and filtering their conversations based on inboxes. This logic should have been part of the conversation permissions service. This PR moves the check to the right place and updates the logic accordingly. Other updates: - Add support for search_conversations service for copilot. - Use PermissionFilterService in contacts/conversations, conversations, copilot search_conversations. --------- Co-authored-by: Sojan <sojan@pepalo.com> Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
18 lines
606 B
Ruby
18 lines
606 B
Ruby
class Api::V1::Accounts::Contacts::ConversationsController < Api::V1::Accounts::Contacts::BaseController
|
|
def index
|
|
# Start with all conversations for this contact
|
|
conversations = Current.account.conversations.includes(
|
|
:assignee, :contact, :inbox, :taggings
|
|
).where(contact_id: @contact.id)
|
|
|
|
# Apply permission-based filtering using the existing service
|
|
conversations = Conversations::PermissionFilterService.new(
|
|
conversations,
|
|
Current.user,
|
|
Current.account
|
|
).perform
|
|
|
|
@conversations = conversations.order(last_activity_at: :desc).limit(20)
|
|
end
|
|
end
|