import type { ChatMessage, ChatMessageType } from './ChatMessage'; /** * The message search directions. * * The message search is based on the Unix timestamp included in messages. Each message contains two Unix timestamps: * - The Unix timestamp when the message is created; * - The Unix timestamp when the message is received by the server. * * Which Unix timestamp is used for message search depends on the setting of {@link sortMessageByServerTime}. * */ export declare enum ChatSearchDirection { /** * Messages are retrieved in the descending order of the timestamp included in them. * */ UP = 0, /** * Messages are retrieved in the ascending order of the timestamp included in them. * */ DOWN = 1 } /** * The conversation types. */ export declare enum ChatConversationType { /** * One-to-one chat. */ PeerChat = 0, /** * Chat group chat. */ GroupChat = 1, /** * Chat room chat. */ RoomChat = 2 } /** * Converts the conversation type from int to enum. * * @param params The conversation type of the int type. * @returns The conversation type of the enum type. */ export declare function ChatConversationTypeFromNumber(params: number): ChatConversationType; /** * Converts the conversation type from enum to string. * * @param params The conversation type of the enum type. * @returns The conversation type of the string type. */ export declare function ChatConversationTypeToString(params: ChatConversationType): string; /** * The conversation class, which defines one-to-one conversations, group conversations, and chat room conversations. * * Each type of conversation involves messages that are sent and received. * * You can get the conversation name by conversation type: * - One-to-one chat: See {@link ChatUserInfoManager#fetchUserInfoById}. * - Group chat: See {@link ChatGroup#getGroupWithId}. * - Chat room: See {@link ChatRoom#fetchChatRoomInfoFromServer}. */ export declare class ChatConversation { /** * The conversation ID. */ convId: string; /** * The conversation type. */ convType: ChatConversationType; /** * Whether the current conversation is a thread conversation. * * - `true`: Yes. * - `false`: No. * * **Note** * This parameter is valid only for group chat.This parameter is valid only for group. */ isChatThread: boolean; /** * The conversation extension. */ ext?: any; constructor(params: { convId: string; convType: ChatConversationType; isChatThread?: boolean; ext?: any; }); /** * Gets the conversation ID. * * @returns The conversation ID. */ name(): Promise; /** * Gets the count of unread messages in the conversation. * * @returns The count of unread messages. * * @throws A description of the exception. See {@link ChatError}. */ getUnreadCount(): Promise; /** * Gets the latest message from the conversation. * * @returns The message instance. The SDK returns `undefined` if the message does not exist. * * @throws A description of the exception. See {@link ChatError}. */ getLatestMessage(): Promise; /** * Gets the latest message received in the conversation. * * @returns The message instance. The SDK returns `undefined` if the message does not exist. * * @throws A description of the exception. See {@link ChatError}. */ getLatestReceivedMessage(): Promise; /** * Sets the extension information of the conversation. * * @param ext The extension information of the conversation. This parameter must be in the key-value format. * * @throws A description of the exception. See {@link ChatError}. */ setConversationExtension(ext: { [key: string]: string | number; }): 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; /** * Updates a message in the local database. * * After you modify a message, the message ID remains unchanged and the SDK automatically updates attributes of the conversation, like `latestMessage`. * * @param msg The message instance. * * @throws A description of the exception. See {@link ChatError}. */ updateMessage(msg: ChatMessage): Promise; /** * Deletes a message from the local database. * * @param msgId The ID of message to delete. * * @throws A description of the exception. See {@link ChatError}. */ deleteMessage(convId: string, convType: ChatConversationType, msgId: string): Promise; /** * Deletes all the messages of the conversation. * * This method 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; /** * Retrieves messages of a certain type that a specified user sends in a conversation. * * @param msgType The message type. See {@link ChatMessageType}. * @param direction The message search direction. See {@link ChatSearchDirection}. * - (Default) `ChatSearchDirection.UP`: Messages are retrieved in the descending order of the Unix timestamp ({@link sortMessageByServerTime}) included in them. * - `ChatSearchDirection.DOWN`: Messages are retrieved in the ascending of the Unix timestamp ({@link sortMessageByServerTime}) included in them. * @param timestamp The starting Unix timestamp in the message for query. The unit is millisecond. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. * If you set this parameter as a negative value, the SDK retrieves messages, starting from the current time, in the descending order of the timestamp included in them. * @param count The maximum number of messages to retrieve each time. The value range is [1,400]. * @param sender The user ID or group ID for retrieval. Usually, it is the conversation ID. * @returns The list of retrieved messages (excluding the one with the starting timestamp). If no message is obtained, an empty list is returned. * * @throws A description of the exception. See {@link ChatError}. */ getMessagesWithMsgType(msgType: ChatMessageType, direction?: ChatSearchDirection, timestamp?: number, count?: number, sender?: string): Promise>; /** * Retrieves messages of a certain quantity in a conversation from the local database. * * **Note** * * The obtained messages will also join the existing messages of the conversation stored in the memory. * * @param startMsgId The starting message ID for query. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. * If this parameter is set as "null" or an empty string, the SDK retrieves messages according to the message search direction while ignoring this parameter. * - If `direction` is set as `ChatSearchDirection.UP`, the SDK retrieves messages, starting from the latest one, in the descending order of the Unix timestamp ({@link sortMessageByServerTime}) included in them. * - If `direction` is set as `ChatSearchDirection.DOWN`, the SDK retrieves messages, starting from the oldest one, in the ascending order of the Unix timestamp ({@link sortMessageByServerTime}) included in them. * @param direction The message search direction. See {@link ChatSearchDirection}. * - (Default) `ChatSearchDirection.UP`: Messages are retrieved in the descending order of the Unix timestamp ({@link sortMessageByServerTime}) included in them. * - `ChatSearchDirection.DOWN`: Messages are retrieved in the ascending order of the Unix timestamp ({@link sortMessageByServerTime}) included in them. * @param loadCount The maximum number of messages to retrieve each time. The value range is [1,400]. * @returns The message list (excluding the ones with the starting or ending timestamp). If no message is obtained, an empty list is returned. * * @throws A description of the exception. See {@link ChatError}. */ getMessages(startMsgId: string, direction?: ChatSearchDirection, loadCount?: number): Promise>; /** * Retrieves messages with keywords in a conversation in the local database. * * @param keywords The keywords for query. * @param direction The message search direction. See {@link ChatSearchDirection}. * - (Default) `ChatSearchDirection.Up`: Messages are retrieved in the descending order of the Unix timestamp ({@link sortMessageByServerTime}) included in them. * - `ChatSearchDirection.Down`: Messages are retrieved in the ascending order of the Unix timestamp ({@link sortMessageByServerTime}) included in them. * @param timestamp The starting Unix timestamp in the message for query. The unit is millisecond. After this parameter is set, the SDK retrieves messages, starting from the specified one, according to the message search direction. * If you set this parameter as a negative value, the SDK retrieves messages, starting from the current time, in the descending order of the the Unix timestamp ({@link sortMessageByServerTime}) included in them. * @param count The maximum number of messages to retrieve each time. The value range is [1,400]. * @param sender The user ID or group ID for retrieval. Usually, it is the conversation ID. * @returns The list of retrieved messages (excluding the one with the starting timestamp). If no message is obtained, an empty list is returned. * * @throws A description of the exception. See {@link ChatError}. */ getMessagesWithKeyword(keywords: string, direction?: ChatSearchDirection, timestamp?: number, count?: number, sender?: string): Promise>; /** * Gets messages that are sent and received in a certain period in a conversation in the local database. * * @param startTime The starting Unix timestamp for search. The unit is millisecond. * @param endTime The ending Unix timestamp for search. The unit is millisecond. * @param direction The message search direction. See {@link ChatSearchDirection}. * - (Default) `ChatSearchDirection.UP`: Messages are retrieved in the descending order of the Unix timestamp ({@link sortMessageByServerTime}) included in them. * - `ChatSearchDirection.DOWN`: Messages are retrieved in the ascending order of the Unix timestamp ({@link sortMessageByServerTime}) included in them. * @param count The maximum number of messages to retrieve each time. The value range is [1,400]. * @returns The list of retrieved messages (excluding the ones with the starting or ending timestamp). If no message is obtained, an empty list is returned. * * @throws A description of the exception. See {@link ChatError}. */ getMessageWithTimestamp(startTime: number, endTime: number, direction?: ChatSearchDirection, count?: number): Promise>; }