import type { ChatMessage, ChatMessageType } from './ChatMessage'; /** * The message search directions. */ export declare enum ChatSearchDirection { /** * Messages are retrieved in the reverse chronological order of the timestamp included in them. */ UP = 0, /** * Messages are retrieved in the chronological order of the timestamp included in them. */ DOWN = 1 } /** * The conversation types. */ export declare enum ChatConversationType { /** * One-to-one chat. */ PeerChat = 0, /** * Group chat. */ GroupChat = 1, /** * Chat room. */ RoomChat = 2 } /** * Conversation type convert from number. * * @param params An integer representing the conversation type. * @returns The conversation type. */ export declare function ChatConversationTypeFromNumber(params: number): ChatConversationType; /** * Conversation type from number. * * @param params A string representing the session type. * @returns The string representing the conversation type. */ export declare function ChatConversationTypeToString(params: ChatConversationType): string; /** * The conversation class, indicating a one-to-one chat, a group chat, or a conversation chat. It contains the messages that are sent and received within the conversation. * * About the conversation name. Please get the name according to different types. * If peer chat type, see {@link ChatUserInfoManager#fetchUserInfoById}. * If group chat type, see {@link ChatGroup#getGroupWithId}. * If room chat type, see {@link ChatRoom#fetchChatRoomInfoFromServer}. */ export declare class ChatConversation { con_id: string; type: ChatConversationType; ext?: any; constructor(params: { con_id: string; type: ChatConversationType; ext?: any; }); /** * Get conversation name. * * @returns The conversation name. */ name(): Promise; /** * Gets the unread message count of the conversation. * * @returns The unread message count of the conversation. * * @throws A description of the exception. See {@link ChatError}. */ fetchUnreadCount(): Promise; /** * Gets the lastest message from the conversation. * * @returns The message instance. Returns undefined if the message does not * * @throws A description of the exception. See {@link ChatError}. */ fetchLatestMessage(): Promise; /** * Gets the latest message from the conversation. * * @returns The message instance. Returns undefined if the message does not exist. * * @throws A description of the exception. See {@link ChatError}. */ fetchLatestReceivedMessage(): Promise; /** * Set custom properties for the conversation. * * @param ext The custom attribute. * * @throws A description of the exception. See {@link ChatError}. */ setConversationExtension(ext: any): Promise; /** * Marks a message as read. * * @param msgId The message id. * * @throws A description of the exception. See {@link ChatError}. */ markMessageAsRead(msgId: string): Promise; /** * Marks all messages as read. * * @throws A description of the exception. See {@link ChatError}. */ markAllMessagesAsRead(): Promise; /** * Inserts a message to a conversation in the local database and the SDK will automatically update the latest message. * * @param msg The message instance. * * @throws A description of the exception. See {@link ChatError}. */ insertMessage(msg: ChatMessage): Promise; /** * Inserts a message to the end of a conversation in the local database. * * @param msg The message instance. * * @throws A description of the exception. See {@link ChatError}. */ appendMessage(msg: ChatMessage): Promise; /** * Updates a message in the local database. * * The latest Message of the conversation and other properties will be updated accordingly. The message ID of the message, however, remains the same. * * @param msg The message instance. * * @throws A description of the exception. See {@link ChatError}. */ updateMessage(msg: ChatMessage): Promise; /** * Deletes a message in the local database. * * @param msgId The ID of message to be deleted. * * @throws A description of the exception. See {@link ChatError}. */ deleteMessage(convId: string, convType: ChatConversationType, msgId: string): Promise; /** * Deletes all the messages of the conversation from both the memory and local database. * * @throws A description of the exception. See {@link ChatError}. */ deleteAllMessages(): Promise; /** * Gets the message with a specific message ID. * * @param msgId The message ID. * @returns The message instance. Returns undefined if the message does not exist. * * @throws A description of the exception. See {@link ChatError}. */ getMessageById(msgId: string): Promise; /** * Retrieves messages from the database according to the following parameters: the message type, the Unix timestamp, max count, sender. * * @param msgType The message type, including TXT, VOICE, IMAGE, and so on. * @param direction The direction in which the message is loaded: ChatSearchDirection. * - `ChatSearchDirection.Up`: Messages are retrieved in the reverse chronological order of when the server received messages. * - `ChatSearchDirection.Down`: Messages are retrieved in the chronological order of when the server received messages. * @param timestamp The Unix timestamp for the search. * @param count The max number of messages to search. * @param sender The sender of the message. The param can also be used to search in group chat or chat room. * @returns The message list. but, maybe is empty list. * * @throws A description of the exception. See {@link ChatError}. */ getMessagesWithMsgType(msgType: ChatMessageType, direction?: ChatSearchDirection, timestamp?: number, count?: number, sender?: string): Promise>; /** * Loads multiple messages from the local database. * * Loads messages from the local database before the specified message. * * The loaded messages will also join the existing messages of the conversation stored in the memory. * * @param startMsgId The starting message ID. Message loaded in the memory before this message ID will be loaded. If the `startMsgId` is set as "" or null, the SDK will first load the latest messages in the database. * @param direction The direction in which the message is loaded: ChatSearchDirection. * @param loadCount The number of messages per page. * @returns The message list. but, maybe is empty list. * * @throws A description of the exception. See {@link ChatError}. */ getMessages(startMsgId: string, direction?: ChatSearchDirection, loadCount?: number): Promise>; /** * Loads messages from the local database by the following parameters: keywords, timestamp, max count, sender, search direction. * * **Note** * Pay attention to the memory usage when the maxCount is large. * * @param keywords The keywords in message. * @param direction The direction in which the message is loaded: ChatSearchDirection. * @param timestamp The timestamp for search. * @param count The maximum number of messages to search. * @param sender The message sender. The param can also be used to search in group chat. * @returns The message list. but, maybe is empty list. * * @throws A description of the exception. See {@link ChatError}. */ getMessagesWithKeyword(keywords: string, direction?: ChatSearchDirection, timestamp?: number, count?: number, sender?: string): Promise>; /** * Loads messages from the local database according the following parameters: start timestamp, end timestamp, count. * * **Note** * Pay attention to the memory usage when the maxCount is large. * * @param startTime The starting Unix timestamp for search. * @param endTime The ending Unix timestamp for search. * @param direction The direction in which the message is loaded: ChatSearchDirection. * @param count The maximum number of message to retrieve. * @returns The list of searched messages. * * @throws A description of the exception. See {@link ChatError}. */ getMessagesFromTime(startTime: number, endTime: number, direction?: ChatSearchDirection, count?: number): Promise>; }