fix the contact inboxed serialisation for active state

This commit is contained in:
Tanmay Sharma
2025-07-22 14:42:12 +04:00
parent 5fcf47bc86
commit 92abd6224e
3 changed files with 7 additions and 3 deletions
@@ -178,7 +178,11 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController
end
def set_include_contact_inboxes
@include_contact_inboxes = params[:include_contact_inboxes] == 'true'
@include_contact_inboxes = if params[:include_contact_inboxes].present?
params[:include_contact_inboxes] == 'true'
else
true
end
end
def fetch_contact
@@ -5,6 +5,6 @@ end
json.payload do
json.array! @contacts do |contact|
json.partial! 'api/v1/models/contact', formats: [:json], resource: contact, with_contact_inboxes: true
json.partial! 'api/v1/models/contact', formats: [:json], resource: contact, with_contact_inboxes: @include_contact_inboxes
end
end
@@ -40,7 +40,7 @@ RSpec.describe 'Contacts API', type: :request do
let!(:contact_inbox) { create(:contact_inbox, contact: contact) }
it 'returns all resolved contacts along with contact inboxes' do
get "/api/v1/accounts/#{account.id}/contacts?include_contact_inboxes=true",
get "/api/v1/accounts/#{account.id}/contacts",
headers: admin.create_new_auth_token,
as: :json