feat: API to list all attachments for a conversation (#7059)

Fixes: https://linear.app/chatwoot/issue/CW-1678/api-to-list-all-attachments-for-a-conversation
This commit is contained in:
Muhsin Keloth
2023-05-12 15:48:06 +05:30
committed by GitHub
parent 708bddf4db
commit 2c3160cfee
6 changed files with 63 additions and 0 deletions

View File

@@ -22,6 +22,10 @@ class Api::V1::Accounts::ConversationsController < Api::V1::Accounts::BaseContro
@conversations_count = result[:count]
end
def attachments
@attachments = @conversation.attachments
end
def create
ActiveRecord::Base.transaction do
@conversation = ConversationBuilder.new(params: params, contact_inbox: @contact_inbox).perform

View File

@@ -95,6 +95,7 @@ class Conversation < ApplicationRecord
has_one :csat_survey_response, dependent: :destroy_async
has_many :conversation_participants, dependent: :destroy_async
has_many :notifications, as: :primary_actor, dependent: :destroy_async
has_many :attachments, through: :messages
before_save :ensure_snooze_until_reset
before_create :mark_conversation_pending_if_bot

View File

@@ -0,0 +1 @@
json.payload @attachments.map(&:push_event_data)