/** * @module Conversations */ import { BehaviorSubject, Subscription } from 'rxjs'; import { CallRB } from '../../models/call.model'; import { Contact } from '../../models/contact.model'; import { BubbleRB } from '../../models/bubble.model'; import { Mention, MentionLegacy, Message, MessageAdditionalContent, MessageID, Reaction, Urgency } from '../../models/message.model'; import { RBEvent } from '../../models/event.model'; import { Conversation, ConversationBookmark, ConversationMissedInfoCounters, ConversationRB, ConversationStatus } from '../../models/conversation.model'; import { FileDescriptor } from '../../models/common/fileDescriptor'; import { SearchTextConvResults, SearchTextResult } from '../../models/searchTextConvResults.model'; import { UrlMetaData } from '../../services/ulrMetadata/urlMetadata.service'; import { Service } from '../../services/service'; import { ConversationServiceBulkHistoryHandler } from '../../services/conversation/conversationServiceBulkHistoryHandler'; import { Bubble, FileDocument, User } from '../../models'; import type { XMLElements } from '../../utils/xmlParser'; /** @internal */ export declare const CONVERSATION_SVC = "ConversationService"; export interface ConversationService { /** * Subscribe to updates from the service (all events are of RBEvent); * @param handler - The call-back function that will be subscribed to the RxJS subject * @param eventNames - array of event to listen */ subscribe(handler: (event: RBEvent) => any, eventNames?: ConversationServiceEvents | ConversationServiceEvents[]): Subscription; /** * Get the array of current conversations */ getConversations(): Conversation[]; /** * Get the array of all current call conversations, regardless of type (phone or webrtc) */ getCallConversations(): Conversation[]; /** * Async method which get conversation for a bubble, a user or via conversation id. * Conversation is first search in service cache then server side. * @param convRef - a bubble, a user or a conversation id * @param type - the conversation type */ getConversation(convRef: string | User | Bubble | undefined, type?: 'contact' | 'room'): Promise; /** * This method remove locally and server side a conversation; Should be used on conversations already created on server and not local ones * @param conversation - the conversation to remove */ removeConversation(conversation: Conversation): Promise; /** * Method used to search for text in all rooms and conversation. The searched text length should be 3+ characters. * This API will return a list of all conversations / rooms with the number of occurances of the searched text in each one. * If you need to get the results for a given conversation/room only, then use this API: searchForTextInConversation * @param searchedText - the text to be searched in all conversations and rooms * @param limit - the maximum number results to take. Default value is 500; */ globalSearch(searchedText: string, limit: number): Promise; } export interface SendMessageData { /** * Additional content (like markdown or vcard) to be added to the message */ additionalContent?: MessageAdditionalContent; /** * In case we want to reply to a given message */ repliedMessage?: Message; /** * The list of mentions inside the message */ mentions?: (Mention | MentionLegacy)[]; /** * The urgency of the message; Allowed values are (standard) 'std', (notify) 'low', (warning) 'middle', (emergency) 'high'; Default value is "std" */ urgency?: Urgency; /** * In case of urgency ACK message, the type of the ACK to send; Accepted values are "ack" or "ignore" */ urgencyAckType?: 'ack' | 'ignore'; /** * URL Meta data in case of sending URL */ urlMetaData?: UrlMetaData; } export interface SendFileMessageData { /** * The file name to be shown in the conversation */ fileName?: string; /** * The File we want to send (in case of upload from local device) */ file?: File; /** * The FileDescriptor (in case of already existing file) * @internal */ existingFile?: FileDescriptor; /** * The Document to send ( in case of already existing document) */ document?: FileDocument; /** * In case of vocal message */ voiceMessageData?: { duration: number; }; /** * The urgency of the message; Allowed values are (standard) 'std', (notify) 'low', (warning) 'middle', (emergency) 'high'; Default value is "std" */ urgency?: Urgency; } /** * @eventProperty */ export declare enum ConversationServiceEvents { /** * @eventProperty * This RBEvent is send when the conversation service is started and ready to be used (also fired after loss of network and reconnection) */ ON_SERVICE_STARTED = "ON_SERVICE_STARTED", /** * @eventProperty ON_CONVERSATION_CREATED * @param conversation - the new conversation * This RBEvent is send when a conversation has been created from the user (or from another client) */ ON_CONVERSATION_CREATED = "ON_CONVERSATION_CREATED", /** * @eventProperty ON_CONVERSATION_REMOVED * @param conversation - the concerned conversation * This RBEvent is send when a conversation has been removed from the user (or from another client) */ ON_CONVERSATION_REMOVED = "ON_CONVERSATION_REMOVED", /** * @eventProperty ON_MESSAGE_ADDED_IN_CONVERSATION * @param conversation - The conversation where the message is being added * This RBEvent is send when a new message is added to a conversation */ ON_MESSAGE_ADDED_IN_CONVERSATION = "ON_MESSAGE_ADDED_IN_CONVERSATION", /** * @eventProperty ON_MESSAGE_MODIFIED_IN_CONVERSATION * @param conversation - The conversation where the message is being modified * This RBEvent is send when a message is being modified (or deleted) in the conversation */ ON_MESSAGE_MODIFIED_IN_CONVERSATION = "ON_MESSAGE_MODIFIED_IN_CONVERSATION", /** * @eventProperty ON_NEW_CALL_IN_CONVERSATION * @param conversation - The conversation to which the call is attached * This RBEvent is send when a new call is added to the conversation; Could be used to manage the list of all conversations with calls */ ON_NEW_CALL_IN_CONVERSATION = "ON_NEW_CALL_IN_CONVERSATION", /** * @eventProperty ON_REMOVE_CALL_IN_CONVERSATION * @param conversation - The conversation to which the call is removed * This RBEvent is send when a new call is removed from the conversation; Could be used to manage the list of all conversations with calls */ ON_REMOVE_CALL_IN_CONVERSATION = "ON_REMOVE_CALL_IN_CONVERSATION", /** * @eventProperty ON_CALL_IN_CONVERSATION_UPDATE * @param conversation - The conversation related to the call (sometimes the converation will be null, as it has been deleted) * @param call - The related call * This RBEvent is send when there's updated in the call inside the conversation; For Telephony calls, the conversation could be null; */ ON_CALL_IN_CONVERSATION_UPDATE = "ON_CALL_IN_CONVERSATION_UPDATE", /** * @eventProperty ON_ACTIVE_CALL_CHANGE * @param conversation - [optional] The conversation where the call is now ACTIVE or RINGING_OUTGOING; COULD BE NULL if no call is active * @param call - [optional] The call hat is now ACTIVE or RINGING_OUTGOING; COULD BE NULL if no call is active (the current call is no longer active) * This RBEvent is send when there's update on the current active call; If no call is currently active, the event will be send with NO CONVERSATION AND NO CALL */ ON_ACTIVE_CALL_CHANGE = "ON_ACTIVE_CALL_CHANGE" } /** * @internal * Conversation service internal events send to other sevices via sendInnerEvent() * Should not be used by SDK user */ export declare enum ConversationServiceInnerEvents { /** * @eventProperty RAINBOW_ON_WEBCONF_ADD_HOC_COMPLETED * @param bubble - the bubble related to the conference * This RBEvent is send when adhoc conference starts in a new conversation; It's used to update the active conversation in the UI */ RAINBOW_ON_WEBCONF_ADD_HOC_COMPLETED = "RAINBOW_ON_WEBCONF_ADD_HOC_COMPLETED", /** * @eventProperty RAINBOW_ON_REPLACE_CONVERSATIONS_IN_EXTERNAL_POPOUT * @param conversation - the conversation related to the update * @param call - the call related to the update * This RBEvent is send in case of switch of conversation call (hybrid cases) and the external popup should update the UI accordingly */ RAINBOW_ON_REPLACE_CONVERSATIONS_IN_EXTERNAL_POPOUT = "RAINBOW_ON_REPLACE_CONVERSATIONS_IN_EXTERNAL_POPOUT", /** * @eventProperty RAINBOW_CONVERSATION_AUTO_ACK_CHECK * @param conversation - the conversation related * @param message - the related message * @param type - We only manage "IM" in case of IM message as the management is different; * @param checkIfChatIsHidden - in case of P2P or CONF cases only * This RBEvent is send in case we need if UCAAS should auto ack received message and decrease the missed counter; */ RAINBOW_CONVERSATION_AUTO_ACK_CHECK = "RAINBOW_CONVERSATION_AUTO_ACK_CHECK", /** * @eventProperty RAINBOW_CONVERSATION_CAPABILITIES_UPDATE * @param conversation - the conversation related * This RBEvent is send in case the capabilities for the conversation have changed */ RAINBOW_CONVERSATION_CAPABILITIES_UPDATE = "RAINBOW_CONVERSATION_CAPABILITIES_UPDATE", /** * @eventProperty RAINBOW_ORDER_CONVERSATIONS * This RBEvent is send in case the an order conversations */ RAINBOW_ORDER_CONVERSATIONS = "RAINBOW_ORDER_CONVERSATIONS" } /** @internal */ export declare class ConversationServiceRB extends Service implements ConversationService { searchTextConvResults: SearchTextConvResults; conversationServiceBulkHistoryHandler: ConversationServiceBulkHistoryHandler | null; readonly missedInfoCounters: BehaviorSubject; pendingMessages: any; private conversations; private conversationCreationPromise; private readonly rxSubject; private readonly innerRxSubject; private isBasicCallAllowed; private isSecondCallAllowed; private isSecondWebrtcCallAllowed; private isSecondWebrtcCallAllowedHybrid; private manageTwoWebrtcCallsAllowed; private activeCall; private subscriptions; private eventServiceSubscriptionHandlers; private xmppSubscriptionHandlers; private conversationServiceEventHandler; private mainService; private eventService; private authService; private xmppService; private i18n; private logger; private profileService; private contactService; private readonly userServicec; private errorHelperService; private settingsService; private botService; private bubbleService?; private fileStorageService?; private fileServerService?; private webConferenceService?; private webrtcP2PService?; private webinarService?; private telephonyService?; private webrtcGatewayService?; private notificationCenterService?; private emojiService?; private reinitTimer; private reinitInProgress; private ccdAgentService; private horizonService; private citrixService; /** This static methods returns the conversationService singleton */ static getInstance(): ConversationServiceRB; /** This static factory creates the conversationService singleton */ static build(): ConversationServiceRB; private constructor(); subscribeToInnerEvents(handler: (event: RBEvent) => any): Subscription; sendInnerEvent(name: ConversationServiceInnerEvents, data?: any): void; /** This async method has to be call to start the conversation service */ start(): Promise; reconnect(): Promise; private removeHandlers; attachHandlers(): void; /** * This async method has to be call to stop the conversation service */ stop(): Promise; subscribe(handler: (event: RBEvent) => any, eventNames?: ConversationServiceEvents | ConversationServiceEvents[]): Subscription; /** * Contact service events send to other services via sendEvent() * Can listen to it via conversationService.subscribe() API * @param name - the name of the event * @param data -the data to be send (an object) */ sendEvent(name: ConversationServiceEvents, data?: unknown): void; /** * Allows to send an event (of type RBEvent) via the RX subject of the instance, and to be captured by subscribe * @param rbEvent - event */ publish(rbEvent: RBEvent): void; private promiseRacer; /** * This async method get valid conversations from the server and update the current list of conversations accordingly */ private getServerConversationsAndUpdate; /** * This async method permits to create a conversation from server data * @param conversationData - the conversation identifier */ private updateConversationFromData; private updateOneToOneConversationInternal; private updateRoomConversationInternal; /** * This async method get valid conversations from the server */ private getServerConversations; /** * This async method create a conversation server side * @param conversation - the conversation to create server side */ private createServerConversation; /** * This async method delete a conversation server side * @param conversationId - the identifier of the conversation to remove server side */ private deleteServerConversation; /** * This async method update a conversation server side * @param conversation - the conversation to update server side */ updateServerConversation(conversation: ConversationRB): Promise; /** * This async method allow to ack all conversation message * @param conversation - the conversation * @param force - when true force the ack */ ackAllMessages(conversation: ConversationRB, force?: boolean): Promise; /** * Method to set or replace a conversation bookmark; This API will provoque an update on the conversation object (event of type ConversationEvents.ON_MESSAGE_BOOKMARKED) * @param conversation - the conversation * @param message - the message to bookmark * @internal */ setConversationBookmark(conversation: ConversationRB, message: Message): Promise; /** * Method to set or delete a conversation bookmark * @param conversation - the conversation * @internal */ deleteConversationBookmark(conversation: ConversationRB): Promise; /** * This async method permits to get a conversation by conversationId * @param jid - the conversation identifier * @param type - the conversation type ('contact' or 'room') (optional) */ getOrCreateConversation(jid: string, type?: string): Promise; private createConversationFromData; /** * This method create a local conversation object from a call * @param call - the call */ getOrCreateTelephonyConversation(call: CallRB): ConversationRB; /** * This method return the pre-existing conversation if any or create a new one * @param conversationId - the conversation identifier * @param conversationDbId - the conversation dbId * @param conversationData - the conversation data received from server */ getOrCreateOneToOneConversationInternal(conversationId: string, conversationDbId?: string, conversationData?: ConversationServerData): Promise; /** * This method return the new bot conversation * @param conversationId - the conversation identifier * @param conversationDbId - the conversation dbId * @param conversationData - the conversation data received from server */ getOrCreateBotConversationInternal(conversationId?: string, conversationDbId?: string, conversationData?: ConversationServerData): Promise; /** * This method return the pre existing room converstion if any or create a new one * @param bubbleId - the bubble identifier, the id or the jid * @param conversationDbId - the conversation dbId * @param conversationData - the conversation data received from server * @param standard - if we should get all users inside the room, or only the strict minimum. Default value is TRUE */ getRoomConversationInternal(bubbleId: string, conversationDbId?: string, conversationData?: ConversationServerData, standard?: boolean): Promise; /** * This method remove locally and server side a conversation; Should be used on conversations already created on server and not local ones; * @param conversation - the conversation to remove */ removeConversation(conversation: Conversation): Promise; /** * This method remove locally a conversation but not from the server * @param conversation - the conversation to remove */ removeLocalConversation(conversation: ConversationRB): void; sendMessage(conversation: ConversationRB, messageText?: string, messageData?: SendMessageData): Message | undefined; sendFileMessage(conversation: ConversationRB, messageData: SendFileMessageData): Promise; forwardMessage(conversation: ConversationRB, destConv: ConversationRB, forwardedMessage: Message, anonymous?: boolean): Promise; addReactionToMessage(conversation: ConversationRB, message: Message, emojiReaction?: string): Promise; removeReactionFromMessage(conversation: ConversationRB, message: Message, emojiReaction?: string): Promise; modifyMessage(conversation: ConversationRB, message: Message, newMessageText?: string, messageData?: SendMessageData): Message; deleteMessage(conversation: ConversationRB, message: Message): void; resendFSMessage(conversation: Conversation, message: Message): Promise; /** * This methods shareFileToViewer * @param conversation - the conversation * @param fileDescriptor - the file descriptor */ private shareFileToViewer; private sendXmppMessage; private addXmppForwardMessage; sendAckReadOrReceivedMessage(conversation: ConversationRB, id: string, event: string): void; sendAckReceivedMessage(conversation: ConversationRB, message: Message): void; sendAckReadMessage(conversation: ConversationRB, message: Message): void; sendAckReadMessages(conversation: ConversationRB): boolean; sendChatStatus(conversation: ConversationRB, status: ConversationStatus): void; sendIsTypingState(conversation: ConversationRB, isTypingState: boolean): void; sendRecordingMessage(conversation: ConversationRB, data: string): Message; /** * removeAllMessages * @param conversation - the conversation */ removeAllMessages(conversation: ConversationRB): Promise; /** * This Methods allow to send the text content of a converstion to the connectedUser email address * @param conversation - the conversation */ sendConversationByEmail(conversation: ConversationRB): Promise; /** * This async method is used to retreive messages around a specified date (for search mechanism) * @param conversation - the conversation * @param msgDate - the centered date */ retrieveMsgByDate(conversation: ConversationRB, msgDate: any, messageId: MessageID): Promise; /** * clear Search result */ clearSearchTextResults(): void; globalSearch(searchedText?: string, limit?: number): Promise; /** * Method used to search for text in a given conversation P2P or room. 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 conversation - the conversation * @param searchedText - the text to be searched in the given P2P or room conversation * @param limit - number of results to get; Default value is 20; */ searchForTextInConversation(conversation: Conversation, 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 conversation - the conversation where we want to load messages * @param timestamp - the timestamp of the message to be loaded * @param nbMessages - the number of messages to load before and after this one */ loadHistoryMessagesAroundGivenMessage(conversation: ConversationRB, timestamp: number, nbMessages?: number): Promise; getConversation(convRef: string | User | Bubble | undefined, type?: 'contact' | 'room'): Promise; getConversations(): Conversation[]; getCallConversations(): Conversation[]; getConversationFromCache(id: string): ConversationRB | undefined; updateMissedCounters(): void; existAnotherCallForContact(call: CallRB): boolean; isTempTelephonyConversation(call: CallRB): boolean; onCallEvent(call: CallRB, fromWebRtcGW?: boolean): Promise; allowDesktopSharing(): boolean; private areWebrtcCallsWithSameContact; updateCallInConversation(call: CallRB): Promise; updateAllCallsCapabilities(): void; updateCallCapabilities(call: CallRB): Promise; private calculateListOfDestinations; private updateWebrtcCallCapabilities; private updatePhoneCallCapabilities; updateConversationCall(conversation: ConversationRB, call: CallRB): void; resetAudioCall(conversation: ConversationRB): void; computeCapabilitiesForContact(user: User, skipUpdateConversation?: boolean): void; computeCapabilitiesForMyContact(): void; shallowEqual(object1: any, object2: any): boolean; onReloadCapabilitiesForMyContactEvent(): void; onContactChangedEvent(contact: Contact): void; onTelephonyStateChangeEvent(): void; onRoomHistoryChangedEvent(room: BubbleRB): void; onRoomAdminMessageEvent(roomJid: string, userJid: string, type: string, msgId: MessageID, extraParameters: any): void; onMyContactChangedEvent(): void; reinit(): Promise; reinitInternal(delay?: number): Promise; private linkAllActiveCallsToConversations; cleanUnwantedConversations(): void; /** * AddChatMessage * @param conversation - the conversation * @param from - the from contact * @param date - ??? * @param data - the message content * @param messageID - the message identifier * @param isSender - ??? * @param subject - ??? * @param answeredMsgId - ??? * @param answeredMsgDate - ??? * @param additionalContent - ??? * @param mentions - ??? * @param urgency - ??? * @param isForwarded - ??? */ addChatMessage(conversation: ConversationRB, from: Contact, date: Date, data: string, messageID: MessageID, isSender: boolean, subject: any, answeredMsgId: any, answeredMsgDate: any, additionalContent: MessageAdditionalContent, mentions: (Mention | MentionLegacy)[], urgency?: any, isForwarded?: any): Message; /** * addAdminBubbleMessage * @param conversation - the conversation * @param from - the message from contact * @param date - the date of the message * @param type - the type of message * @param messageId - the message identifier * @param translatedMessage -the translatedMessage */ addAdminBubbleMessage(conversation: ConversationRB, from: Contact, date: any, type: string, messageId: MessageID, translatedMessage?: any): Message; private addFSMessage; private addForwardChatMessage; addRecordingMessage(conversation: ConversationRB, from: Contact, date: Date, data: any, messageId: MessageID): Message; addFileMessage(conversation: ConversationRB, from: Contact, date: any, data: any, messageID: any, urgency?: Urgency): Message; addFileSharingMessage(conversation: ConversationRB, from: any, date: any, data: any, messageID: any, fileId: any, fileName: any, geoloc: any, urgency: Urgency, isForwarded: boolean): Message; addWebRTCMessage(conversation: ConversationRB, from: Contact, date: any, data: any, messageID: any): Message; addPinMessage(conversation: ConversationRB, from: Contact, date: any, data: any, messageID: any): Message; addShareRecapMessage(conversation: ConversationRB, from: Contact, date: any, data: any, messageID: any, additionalContent: MessageAdditionalContent): Message; addPollMessage(conversation: ConversationRB, from: Contact, date: any, data: any, messageID: any, additionalContent: MessageAdditionalContent): Message; private addMessage; setStatusMessage(conversation: ConversationRB, from: Contact, status: ConversationStatus): void; onCallStatusChange(call: CallRB): void; private shortnameToUnicode; /** * Process stanza object to extract mentions * @param body - message body to process * @param mentionElem - mention XMPP XML element containing the mentions * @returns */ processStanzaMentions(body: string, mentionElem: XMLElements): { body: string; mentions: Mention[]; }; processStanzaReaction(reactionsElem: XMLElements): Map; processStanzaReactionsCount(reactionsCountElem: XMLElements): Map; /** * Transform mention strings back to normal string text * @param message - the message object * @param body - the message string */ transformMessageToText(body: string): string; } /** * @internal * This interface describes the data received from server when creating / getting conversation */ export interface ConversationServerData { /** * The JID IM of the distant party */ jid_im?: string; /** * The DB ID of the conversation itself */ id?: string; /** *The type of the conversation (user, room, bot) */ type?: string; /** * The last message date in string */ lastMessageDate?: string; /** * The last msg text in the conversation */ lastMessageText?: string; /** * if the conversation is muted */ mute?: boolean; /** * The number of not ACK READ read IMs */ unreadMessageNumber?: string; /** * The creation date of the conversation in string */ creationDate?: string; /** * The JID IM of the user that send the last message */ lastMessageSender?: string; /** * In case of call event in the conversation (P2P only) */ call?: null | object; /** * If the last message was modified */ modified?: boolean; /** * The JID IM of the user that forwarded the messages */ forwardFrom?: string; /** * The forwarded message */ forwardedMessage?: string; /** * If the user in the conversation has the right to use IM (p2p only) */ instantMessagesCustomisation?: string; /** * If the user in the conversation has the right to ACK messages (p2p only) */ readReceiptsCustomisation?: string; /** * If the user in the conversation has the right to use screen sharing */ useScreenSharingCustomisation?: string; /** * If the user in the conversation has the right to use audio */ useWebRTCAudioCustomisation?: string; /** * If the user in the conversation has the right to use video sharing */ useWebRTCVideoCustomisation?: string; /** * The filename */ filename?: string; /** * If the last messages is geoloc */ geoloc?: boolean; /** * The last message content type (for markdown things) */ contentType?: string; /** * Bookmark infos for the conversatiokn */ bookmark?: ConversationBookmark; /** * The topic (description) of the bubble */ topic?: string; /** * The type of the last event (in case of conference started) */ eventName?: string; /** * The JID IM of the user related to the event */ eventJid?: string; /** * If we can make a call shift for this conversation */ callShift?: boolean; } //# sourceMappingURL=conversation.service.d.ts.map