import { GraphId } from '../../types/resources/group_resource' import { GetRequest } from '../client/types' export interface ConversationRequestArgs { gids: string chat_group_graph_id?: GraphId group_source_app_name?: string show_direct_messages?: boolean show_archived?: boolean } export const getConversationsRequestArgs = ({ gids, chat_group_graph_id, group_source_app_name, show_direct_messages, show_archived, }: Partial = {}): GetRequest => { let filter: string if (chat_group_graph_id) { filter = 'mine_or_not_empty,group' } else if (show_archived) { filter = 'mine_or_not_empty,archived' } else if (show_direct_messages) { filter = 'mine_or_not_empty,direct_message' } else if (group_source_app_name) { filter = 'mine_or_not_empty,group_source_app_name' } else { filter = 'mine_or_not_empty' } return { url: '/me/conversations', data: { perPage: 20, order: '-last_message', filter, gids, group: chat_group_graph_id, group_source_app_name, fields: { Conversation: [ 'created_at', 'badges', 'conversation_preview', 'disabled', 'disabled_reason', 'disabled_message', 'groups', 'last_message_author_id', 'last_message_author_name', 'last_message_created_at', 'last_message_text_preview', 'preview_avatar_urls', 'custom_avatar_type', 'custom_avatar_key', 'custom_avatar_color', 'custom_avatar_image_url', 'member_ability', 'muted', 'replies_disabled', 'title', 'unread_count', 'unread_reaction', 'updated_at', ], AnalyticsMetadata: ['metadata'], ConversationBadge: ['app_name', 'pco_resource_type', 'text'], }, include: ['badges', 'analytics_metadata'], }, } }