/** * @module Conversations */ import { Contact } from '../models/contact.model'; import { Call, CallRB } from '../models/call.model'; import { Bubble, BubbleRB } from '../models/bubble.model'; import { Subscription } from 'rxjs'; import { AnswerMessage, Message, MessageID, MessageSide, Urgency } from './message.model'; import type { Webinar } from '../models/webinar.model'; import { RBEvent } from './event.model'; import { SendFileMessageData, SendMessageData } from '../services/conversation/conversation.service'; import { User } from './user.model'; import { SearchTextResult } from './searchTextConvResults.model'; import { FileDocument } from './fileDocument.model'; import { EmitableService, EventableService } from '../services/service'; import { MaybeArray } from '../typings/helpers'; /** * Conversation public events * @eventProperty */ export declare enum ConversationEvents { /** * @eventProperty * This RBEvent is send when a new message is added in this conversation */ ON_MESSAGE_ADDED = "ON_MESSAGE_ADDED", /** * @eventProperty * This RBEvent is send when the replaced/deleted message is the last one */ ON_MESSAGE_REPLACED = "ON_MESSAGE_REPLACED", /** * @eventProperty * This RBEvent is send when a bookmark is set in this conversation */ ON_MESSAGE_BOOKMARKED = "ON_MESSAGE_BOOKMARKED", /** * @eventProperty * This RBEvent is send when a message is add in the "cache message". * This "cache message" is used to store messages which belongs to the conversation but not * already loaded. For example an old replied message. */ ON_MESSAGE_CACHED = "ON_MESSAGE_CACHED", /** * @eventProperty * This RBEvent is send when something occurs on conversation messages */ ON_MESSAGES_UPDATED = "ON_MESSAGES_UPDATED", /** * @eventProperty * This RBEvent is send when conversation messages are cleared */ ON_MESSAGES_CLEARED = "ON_MESSAGES_CLEARED", /** * @eventProperty * This RBEvent is send when the missed message counter is updated */ ON_MISSED_COUNTER_UPDATED = "ON_MISSED_COUNTER_UPDATED", /** * @eventProperty * This RBEvent is send when the conversation status is changed * This status represent the user typing activity. * + ACTIVE * + INACTIVE * + COMPOSING * + PAUSED */ ON_STATUS_CHANGED = "ON_STATUS_CHANGED", /** * @eventProperty * This RBEvent is send when * In some situations when the call is "remotely picked" by another client and we update the tel call area (??) * In some situations to manage the mute / unmute / sharing buttons in tell call area; * This event is to be DELETED and replaced with something else; */ RAINBOW_CONVERSATION_CALL_UPDATE = "RAINBOW_CONVERSATION_CALL_UPDATE", /** * @eventProperty * @internal * This RBEvent is send when the contact is replced by a new one in the conversation : * It is used in the following usecases: * - PBX Hybride (OXO/OXE) conference call is "reverted" to single call * - temp contact replaced by a directory contact * As the conversation stays the same, we only modify the "contact" inside to adapt to the new situation. */ ON_CONVERSATION_CALL_CONTACT_CHANGE = "ON_CONVERSATION_CALL_CONTACT_CHANGE", /** * @eventProperty * @internal * This RBEvent is send when * FIXME : MCO GUI EVENT */ ON_CONVERSATION_CALL_SHIFT_CHANGE = "ON_CONVERSATION_CALL_SHIFT_CHANGE", /** * @eventProperty * @internal * This RBEvent is send when * FIXME : MCO GUI EVENT */ RAINBOW_CONVERSATION_USER_UPDATED = "RAINBOW_CONVERSATION_USER_UPDATED", /** * @eventProperty * @internal * This RBEvent is send when * FIXME : MCO GUI EVENT */ RAINBOW_CONVERSATION_ROOM_UPDATED = "RAINBOW_CONVERSATION_ROOM_UPDATED", /** * @eventProperty * @internal * This RBEvent is send when * FIXME : MCO WRONG PLACE : SFUCALLAREA SERVICE EVENT : GUI */ RAINBOW_CONVERSATION_REQUEST_TRANSFERT_SHARING = "RAINBOW_CONVERSATION_REQUEST_TRANSFERT_SHARING", /** * @eventProperty * @internal * This RBEvent is send when * FIXME : MCO WRONG PLACE : SFUCALLAREA SERVICE EVENT : GUI */ RAINBOW_CONVERSATION_ACCEPT_TRANSFERT_SHARING = "RAINBOW_CONVERSATION_ACCEPT_TRANSFERT_SHARING", /** * @eventProperty * @internal * This RBEvent is send when the conversation urgency level is reset * FIXME : MCO GUI EVENT */ RAINBOW_CONVERSATION_RESET_MESSAGE_LEVEL = "RAINBOW_CONVERSATION_RESET_MESSAGE_LEVEL", /** * @eventProperty * @internal * This RBEvent is send when * FIXME : MCO GUI EVENT */ RAINBOW_CONVERSATION_INFO_VISIBLE = "RAINBOW_CONVERSATION_INFO_VISIBLE" } /** * Conversation public events */ export interface IConversationEvents { /** * @eventProperty * This RBEvent is send when a new message is added in this conversation */ ON_MESSAGE_ADDED: { message: Message; }; /** * @eventProperty * This RBEvent is send when the replaced/deleted message is the last one */ ON_MESSAGE_REPLACED: { message: Message; }; /** * @eventProperty * This RBEvent is send when a bookmark is set in this conversation */ ON_MESSAGE_BOOKMARKED: { bookmark: ConversationBookmark; }; /** * @eventProperty * This RBEvent is send when a message is add in the "cache message". * This "cache message" is used to store messages which belongs to the conversation but not * already loaded. For example an old replied message. */ ON_MESSAGE_CACHED: { message: Message; }; /** * @eventProperty * This RBEvent is send when something occurs on conversation messages */ ON_MESSAGES_UPDATED: unknown; /** * @eventProperty * This RBEvent is send when conversation messages are cleared */ ON_MESSAGES_CLEARED: unknown; /** * @eventProperty * This RBEvent is send when the missed message counter is updated */ ON_MISSED_COUNTER_UPDATED: { missedCounter: number; }; /** * @eventProperty * This RBEvent is send when the conversation status is changed * This status represent the user typing activity. * + ACTIVE * + INACTIVE * + COMPOSING * + PAUSED */ ON_STATUS_CHANGED: { status: ConversationStatus; composers: User[]; }; /** * @eventProperty * This RBEvent is send when * In some situations when the call is "remotely picked" by another client and we update the tel call area (??) * In some situations to manage the mute / unmute / sharing buttons in tell call area; * This event is to be DELETED and replaced with something else; */ RAINBOW_CONVERSATION_CALL_UPDATE: { call: Call; }; /** * @eventProperty * @internal * This RBEvent is send when the contact is replced by a new one in the conversation : * It is used in the following usecases: * - PBX Hybride (OXO/OXE) conference call is "reverted" to single call * - temp contact replaced by a directory contact * As the conversation stays the same, we only modify the "contact" inside to adapt to the new situation. */ ON_CONVERSATION_CALL_CONTACT_CHANGE: { call: Call; }; /** * @eventProperty * @internal * This RBEvent is send when * FIXME : MCO GUI EVENT */ ON_CONVERSATION_CALL_SHIFT_CHANGE: unknown; /** * @eventProperty * @internal * This RBEvent is send when * FIXME : MCO GUI EVENT */ RAINBOW_CONVERSATION_USER_UPDATED: unknown; /** * @eventProperty * @internal * This RBEvent is send when * FIXME : MCO GUI EVENT */ RAINBOW_CONVERSATION_ROOM_UPDATED: unknown; /** * @eventProperty * @internal * This RBEvent is send when * FIXME : MCO GUI EVENT */ RAINBOW_CONVERSATION_INFO_VISIBLE: unknown; /** * @eventProperty * @internal * This RBEvent is send when the conversation urgency level is reset * FIXME : MCO GUI EVENT */ RAINBOW_CONVERSATION_RESET_MESSAGE_LEVEL: unknown; /** * @eventProperty * @internal * This RBEvent is send when * FIXME : MCO WRONG PLACE : SFUCALLAREA SERVICE EVENT : GUI */ RAINBOW_CONVERSATION_REQUEST_TRANSFERT_SHARING: { fromContact: any; from: any; }; /** * @eventProperty * @internal * This RBEvent is send when * FIXME : MCO WRONG PLACE : SFUCALLAREA SERVICE EVENT : GUI */ RAINBOW_CONVERSATION_ACCEPT_TRANSFERT_SHARING: { fromContact: any; from: any; }; } /** * This enum is used to represent the type of the conversation */ export declare enum ConversationType { P2P = "P2P", BUBBLE = "BUBBLE", BOT = "BOT" } /** * This enum is used to represent the status of the conversation */ export declare enum ConversationStatus { ACTIVE = "active", INACTIVE = "inactive", COMPOSING = "composing", PAUSED = "paused" } export interface DocumentMessageData { /** * The document name to be shown in the conversation */ documentName?: string; /** * The Document to send ( in case of already existing document) */ document?: FileDocument; /** * The urgency of the message; Allowed values are (standard) 'std', (notify) 'low', (warning) 'middle', (emergency) 'high'; Default value is "std" */ urgency?: Urgency; } export declare class ConversationLastMessage { /** * @internal */ constructor(); /** * The text of the last message received of the conversation * @readonly */ text: string; /** * The content type of the last message received of the conversation * @readonly */ contentType: string; /** * The ID of the user for the last message * @readonly */ sender: string | null; /** * The Side of the Last message. * + LEFT * + RIGHT * + ADMIN * @readonly */ side?: MessageSide; /** * The ID the last message replaced by * @readonly */ messageId: string; /** * Allow to reset the lastMessage parameters */ reset(): void; } /** * This class is used to represent a conversation capabilities */ export declare class ConversationCapabilities { /** * @internal */ constructor(); /** * User can make or receive telephony calls */ telephony: boolean; /** * User can make / receive webrtc calls */ webRTC: boolean; /** * User can make a desktop sharing call with that user */ sharedDesktop: boolean; /** * Means telephony || webRTC is TRUE */ mediaAvailable: boolean; /** * True if user is already in call and has an active fullJid */ addMedia: boolean; } /** * This class is used to represent a conversation missed info counters */ export declare class ConversationMissedInfoCounters { /** * @internal */ constructor(); /** * @internal */ static create(): ConversationMissedInfoCounters; missedIMCounter: number; missedIMDetails: any[]; } export declare class ConversationBookmark { /** * @internal */ constructor(); messageId: MessageID; timestamp: number; } export type MessageLevel = 'standard' | 'notify' | 'warning' | 'emergency'; /** * A conversation modelize an interaction between one or more Rainbow users. * In the Rainbow ecosystem we'll come across two types of conversations: * + The "peer-to-peer" (P2P) conversations : where two Rainbow users interact with each other. * + The "bubble" conversations : where several users interact all together. */ export interface Conversation extends EventableService { /** * The conversation ID * @readonly */ id: string; /** * The database ID * @readonly */ dbId?: string; /** * The conversation name * @readonly */ name?: string; /** * The type of the conversation. Can be P2P (0), BUBBLE (1) or BOT (2) * @readonly */ type?: ConversationType; /** * (P2P conversation only) The recipient of the conversation * @readonly */ user?: User; /** * (Bubble conversation only) The conversation Bubble if any * @readonly */ bubble?: Bubble; /** * The capabilities of the conversation * @readonly */ capabilities?: ConversationCapabilities; /** * The name of the conversation (the display name of the recipient for P2P conversation or the room name for a BUBBLE conversation) * @readonly */ filterName: string; /** * The number of instant messages not read * @readonly */ missedCounter: number; /** * The list of messages downloaded for this conversation * @readonly */ messages: Message[]; /** * The status of the conversation * @readonly */ status: ConversationStatus; /** * The date of the last modification of the conversation * @readonly */ lastModification?: Date; /** * The date of the creation of the conversation * @readonly */ creationDate?: Date; /** * The last message received of the conversation * @readonly */ lastMessage: ConversationLastMessage; /** * If the last message that is forwarded is a file * @readonly */ isForwardedMessageFile: boolean; /** * The last message forwarded * @readonly */ forwardedMessage: string; /** * TRUE if conversation favorite * @readonly */ isFavorite: boolean; /** * The bookmarked message in the conversation */ bookmark: ConversationBookmark; /** * True if this conversation is a webinar conversation * @readonly */ isWebinarConversation: boolean; /** * The webinar associated to this conversation (if any) * @readonly */ webinar?: Webinar; call: CallRB; /** * Subscribe to updates on the current conversation (all events are of RBEvent type); * @param handler - The call-back function that will be subscribed to the RxJS subject * @param filterEvent - a list of event names that the user wants to receive when subscribing (used a filter) */ subscribe(handler: (event: RBEvent) => any, filterEvent?: MaybeArray): Subscription; /** * This method allows us to retrieve archived message pages. * By default, no message history is loaded, but this method will allow us to retrieve them page by page. * @param nbMessages - the number of messages to get in this page */ getHistoryPage(nbMessages: number): Promise; /** * Return all the already loaded messages */ getMessages(): Message[]; /** * Remove given message from the conversation (should be a message that the user has sent) * @param message - the message we want to delete */ deleteMessage(message: Message): void; /** * Remove all message of the conversation */ deleteAllMessages(): Promise; /** * Return the message with the corresponding identifier * @param messId - the message identifier * @param searchInCache - if true this methods start to search in cacheMessage * @returns the search message if founded undefined else */ getMessageById(messId: MessageID, searchInCache?: boolean): Message | undefined; /** * This method permits to send a chat Message * @param messageText - the text to be send * @param messageData - the message data object * @returns the sent message (or undefined in case of an issue) */ sendMessage(messageText: string, messageData?: SendMessageData): Message | undefined; /** * This method permits to send a file Message * @param messageData - The document message data to be send */ sendFileMessage(messageData: SendFileMessageData): Promise; /** * This method permits to send a file document message * @param messageData - The file message data to be send */ sendFileDocumentMessage(messageData: DocumentMessageData): Promise; /** * Method to set or replace conversation bookmark * This API will provoque an update on the conversation object (event of type ConversationEvents.ON_MESSAGE_BOOKMARKED) * @param message - the message to bookmark */ setBookmark(message: Message): Promise; /** * Method to delete a conversation bookmark */ deleteBookmark(): Promise; /** * This API can be used to add an emoji reaction to an already existing message. * @param message - The Message we want to react to * @param emojiReaction - The emoji reaction to add * @returns the updated message or undefined in case of issue */ addReactionToMessage(message: Message, emojiReaction?: string): Promise; /** * The API can be used to remove an emoji reaction we previously added from a message * @param message - The message from which we want to remove the reaction * @param emojiReaction - The emoji reaction to remove * @returns the updated message or undefined in case of issue */ removeReactionFromMessage(message: Message, emojiReaction?: string): Promise; /** * This API can be used to modify an already existing sent message; The user is allowed to modify the text of the message, the additional content and the mentions; * NB The new SendMessageData will replace the existing data, so all the existing informations (additionalContent or mentions) should also be added in the data otherwise they'll be removed * @param message - The Message we want to modify * @param newMessageText - The new text of the message * @param messageData - the updated send message data * @returns the updated message or undefined in case of issue */ modifyMessage(message: Message, newMessageText?: string, messageData?: SendMessageData): Message; /** * This method permits to forward a Message to another conversation * @param destConv - conversation to which the Message is forwarded * @param message - the message to forward * @param anonymous - allow to specify if yes or not the message orioginbator has to be displayed (default: true) */ forwardMessage(destConv: Conversation, message: Message, anonymous?: boolean): Promise; /** * This method permits to send a "typing" (or remove it) state to the distant party; * @param isTypingState - if the user is currently "typing" inside the conversation */ sendIsTypingState(isTypingState: boolean): void; /** * This API permit to send the text content of the conversation at the connectUser e-mail address. */ sendByEmail(): Promise; /** * This method permits to send a ACK READ status for message to mark it as READ * @param message - the chat message to "ACK read" */ ackReadMessage(message: Message): void; /** * This method permits to send a ACK READ all received messages inside the conversation */ ackReadMessages(): boolean; /** * Method used to search for text in a given conversation P2P or bulle. The searched text length should be 3+ characters. * This API will return a SearchTextResult that contains the list of IDs of messages to be searched after that * @param searchedText - the text to be searched * @param limit - number of results to get; Default value is 20; */ searchForText(searchedText: string, limit: number): Promise; /** * Method used to load the messages around a given timestamp. Can be used when we search for a message via API searchForTextInConversation * and then we want to load the message (or also the messages around it); This API will load the messages in the conversation list of messages and resolve once it's done; * @param timestamp - the timestamp of the message to be loaded * @param nbMessages - the number of messages to load before and after this one */ loadHistoryMessagesAroundGivenMessage(timestamp: number, nbMessages: number): Promise; /** * JSON serialisation of conversation for debug purpose */ toJSON(): any; } /** * @internal * This class is used to represent a conversation */ export declare class ConversationRB implements Conversation, EmitableService { private static randomBase; private static messageId; static ChatstatesNS: string; static ReceiptNS: string; static contentNS: string; static AttentionNS: string; static FORWARDNS: string; static createConversation(peer: Contact | BubbleRB): ConversationRB; static getUniqueMessageId(): MessageID; id: string; dbId?: string; type?: ConversationType; filterName: string; contact: Contact | null; bubble?: BubbleRB; infoVisible: boolean; capabilities?: ConversationCapabilities; missedCounter: number; missedCalls: number; messages: Message[]; participantStatuses: Record; status: ConversationStatus; historyIndex: number; historyLastIndex: number; historyMessages: Message[]; historyDefered: any; historyAboveComplete: boolean; historyBelowComplete: boolean; currentHistoryIndex?: number; lastModification?: Date; creationDate?: Date; lastMessage: ConversationLastMessage; forwardFrom: any; forwardedMessage: any; pip: boolean; videoCall: CallRB | null; audioCall: CallRB | null; muted: boolean; isMutedAudio: boolean; largeInfoVisible: boolean; selectedTabName: string; isFavorite: boolean; cacheMessages: Message[]; telephonyContacts: any; isWebinarConversation: boolean; webinar?: Webinar; lastCallInfo: any; isForwardedMessageFile: boolean; isGeoLoc?: boolean; private _isDraft; replyData: AnswerMessage; lastEvent: any; private _callShift; private _bookmark; private readonly rxSubject; get getNameForLogs(): string; get bookmark(): ConversationBookmark; set bookmark(value: ConversationBookmark); private _shouldRemoveBookMark; get shouldRemoveBookMark(): boolean; set shouldRemoveBookMark(value: boolean); get room(): BubbleRB; set room(value: BubbleRB); get isDraft(): boolean; set isDraft(value: boolean); set callShift(callShift: boolean); get callShift(): boolean; get call(): CallRB; get name(): string; get user(): User; private conversationService?; getHistoryPage(nbMessages?: number): Promise; getMessages(): Message[]; sendMessage(messageText: string, messageData?: SendMessageData): Message | undefined; sendFileDocumentMessage(messageData: DocumentMessageData): Promise; sendFileMessage(messageData: SendFileMessageData): Promise; deleteMessage(message: Message): void; deleteAllMessages(): Promise; setBookmark(message: Message): Promise; deleteBookmark(): Promise; addReactionToMessage(message: Message, emojiReaction?: string): Promise; removeReactionFromMessage(message: Message, emojiReaction?: string): Promise; modifyMessage(message: Message, newMessageText?: string, messageData?: SendMessageData): Message; forwardMessage(destConv: Conversation, message: Message, anonymous?: boolean): Promise; sendIsTypingState(isTypingState: boolean): void; sendByEmail(): Promise; ackReadMessage(message: Message): void; ackReadMessages(): boolean; searchForText(searchedText: string, limit?: number): Promise; loadHistoryMessagesAroundGivenMessage(timestamp: number, loadAround: number): Promise; constructor(conversationId: string); /** * Search in cache the message with the corresponding identifier * @param messId - the message identifier */ private getMessageInCacheById; getMessageById(messId: MessageID, searchInCache?: boolean): Message; /** * Search in history the message with the corresponding identifier * @param messId - the message identifier */ getMessageByIdInHistory(messId: MessageID): Message; /** * get a replaced message by identifier * @param messId - the message identifier */ getReplacedMessageById(messId: MessageID): Message | null; /** * Reset conversation instance */ reset(): void; resetHistoryInfo(): void; subscribe(handler: (event: RBEvent) => any, eventNames?: MaybeArray): Subscription; events(...eventNames: EventNames[]): import("rxjs").Observable>>; sendEvent(eventName: EventName, data: IConversationEvents[EventName]): void; /** * Subscribe to conversation change observable * @param missedCounter - the missed message value to set */ setMissedCounter(missedCounter: number): void; /** * Check if conversation has an incomming call */ isAudioCallIncomming(): boolean; /** * Add message in history messages * @param message - the message */ addMessageInHistoryMessages(message: Message): void; /** * Add message in the cache (these are messages that are part of the conversation but often not in the right place, like in case * of some old reply or something like that, so the message is added in the cache and not in the list of messages, as it's separated) * @param message - the message */ addMessageInCacheMessages(message: Message): void; ackReadAllSentMessages: () => void; ackReceivedAllSentMessages(): void; /** * Marks all received messages as READ */ ackReadAllReceivedMessages(): boolean; updateAfterReplaceEvent(message: Message): void; toJSON(): any; } //# sourceMappingURL=conversation.model.d.ts.map