Compare commits

...
2 changed files with 10 additions and 0 deletions
@@ -160,6 +160,9 @@ class Api::V1::Accounts::ConversationsController < Api::V1::Accounts::BaseContro
def conversation
@conversation ||= Current.account.conversations.find_by!(display_id: params[:id])
# Return 404 if conversation has no valid contact or contact_inbox
raise ActiveRecord::RecordNotFound if @conversation.contact.blank?
authorize @conversation, :show?
end
+7
View File
@@ -63,6 +63,7 @@ class ConversationFinder
set_assignee_type
find_all_conversations
filter_orphan_conversations
filter_by_status unless params[:q]
filter_by_team
filter_by_labels
@@ -166,6 +167,12 @@ class ConversationFinder
@conversations = @conversations.where(contact_inboxes: { source_id: params[:source_id] })
end
def filter_orphan_conversations
# Filter out conversations where the contact has been deleted
# Using INNER JOIN is most efficient - only returns conversations with existing contacts
@conversations = @conversations.joins(:contact)
end
def set_count_for_all_conversations
[
@conversations.assigned_to(current_user).count,