import { ConnectedUserInit, ConnectedUserMedia, Contact } from '../../models/contact.model'; import { Observable, Subscription } from 'rxjs'; import { EventableService, RbServiceEvent, Service } from '../../services/service'; import { MaybeArray } from 'date-fns'; import { UserNetworkService } from '../../services/core/userNetwork.service'; import { DirectoryInternalSearchResults, DirectorySearchOptions } from './directorySearch.service'; import { User } from '../../models'; import { ConnectedUser, ConnectedUserProfile, ConnectedUserRB, DisplayOrder, UserCustomData, UserCustomStatus, UserExternalPresenceStatus, UserPresenceStatus, UsersByEmailsResult, WebCallCapabilities } from '../../models/user.model'; /** @internal */ export declare const CONTACT_SVC = "ContactService"; /** * The data to be sent when we want to update our user; NB If fileds are not present, they wont be updated on server ! * A basic example: * ```ts * { "firstName": "Hello", * "lastName": "World", * "title": "MR", * "nickName": "Worldwide", * "jobTitle": "Rainbow SDK guru", * "country": "EN", * "language": "en", * "emails": [ * { * "email": "work@work.en", * "type": "work" * }, * { * "email": "home@home.en", * "type": "home" * } * ], * "phoneNumbers": [ * // corresponds to the phonePro property of contact * { * "number": "12345", * "type": "work", * "deviceType": "landline" * }, * * // corresponds to the mobilePro property of contact * { * "number": "12534", * "type": "work", * "deviceType": "mobile", * "isVisibleByOthers": false * }, * * // corresponds to the phonePerso property of contact * { * "number": "111111", * "type": "home", * "deviceType": "landline", * "isVisibleByOthers": false * }, * * // corresponds to the mobilePerso property of contact * { * "number": "22222", * "type": "home", * "deviceType": "mobile", * "isVisibleByOthers": false * } * ] * } * ``` */ /** * Contact service events sent to other services via sendEvent() * Can listen to it via contactService.subscribe() API * @internal * @eventProperty */ export declare enum ContactServiceEvents { /** * @eventProperty ON_CONNECTED_USER_PRESENCE_CHANGE * This RB event is sent when the presence of the connected user changes. * It's sent via the innerEvent system. * Used by conversation service to calculate the capabilities of contact in case of presence change of user. */ ON_CONNECTED_USER_PRESENCE_CHANGE = "ON_CONNECTED_USER_PRESENCE_CHANGE", /** * @eventProperty ON_USER_PRESENCE_CHANGE * This RB event is sent when the presence of any user changes. * It's sent via the innerEvent system. * Used by conversation service to calculate the capabilities of contact in case of presence change of user. */ ON_USER_PRESENCE_CHANGE = "ON_USER_PRESENCE_CHANGE", /** * @eventProperty ON_CONTACT_SERVICE_STARTED * This RB event is sent when the contact service is started and ready to be used. */ ON_CONTACT_SERVICE_STARTED = "ON_CONTACT_SERVICE_STARTED", /** * @eventProperty ON_CONNECTED_USER_ROSTER_CHANGE * This RB event is sent when a new contact is added or removed to/from the roster of the connected user. */ ON_CONNECTED_USER_ROSTER_CHANGE = "ON_CONNECTED_USER_ROSTER_CHANGE", /** * @eventProperty ON_CONNECTED_USER_CUSTOM_STATUS_CHANGE * This RB event is sent when the custom status of the connected user changes. * It's sent via the innerEvent system. */ ON_CONNECTED_USER_CUSTOM_STATUS_CHANGE = "ON_CONNECTED_USER_CUSTOM_STATUS_CHANGE", /** * @eventProperty ON_USER_CUSTOM_STATUS_CHANGE * This RB event is sent when the custom status of any user changes. * It's sent via the innerEvent system. */ ON_USER_CUSTOM_STATUS_CHANGE = "ON_USER_CUSTOM_STATUS_CHANGE", /** * @eventProperty ON_CONNECTED_USER__OXEPREFERREDTRUNK_CHANGE * This RB event is sent when OXE PREFERREDTRUNK of connected user changes. * It's sent via the innerEvent system. */ ON_CONNECTED_USER__OXEPREFERREDTRUNK_CHANGE = "ON_CONNECTED_USER__OXEPREFERREDTRUNK_CHANGE" } /** * Contact service events sent to other services via sendEvent() * Can listen to it via contactService.events().subscribe() API * @internal * @eventProperty */ export interface IContactServiceEvents { /** * @eventProperty ON_CONNECTED_USER_PRESENCE_CHANGE * This RB event is sent when the presence of the connected user changes. * It's sent via the innerEvent system. * Used by conversation service to calculate the capabilities of contact in case of presence change of user. */ ON_CONNECTED_USER_PRESENCE_CHANGE: Contact; /** * @eventProperty ON_USER_PRESENCE_CHANGE * This RB event is sent when the presence of any user changes. * It's sent via the innerEvent system. * Used by conversation service to calculate the capabilities of contact in case of presence change of user. */ ON_USER_PRESENCE_CHANGE: Contact; /** * @eventProperty ON_CONTACT_SERVICE_STARTED * This RB event is sent when the contact service is started and ready to be used. */ ON_CONTACT_SERVICE_STARTED: unknown; /** * @eventProperty ON_CONNECTED_USER_ROSTER_CHANGE * This RB event is sent when a new contact is added or removed to/from the roster of the connected user. */ ON_CONNECTED_USER_ROSTER_CHANGE: { contact: Contact; action: string; }; /** * @eventProperty ON_CONNECTED_USER_CUSTOM_STATUS_CHANGE * This RB event is sent when the custom status of the connected user changes. * It's sent via the innerEvent system. */ ON_CONNECTED_USER_CUSTOM_STATUS_CHANGE: ConnectedUser; /** * @eventProperty ON_USER_CUSTOM_STATUS_CHANGE * This RB event is sent when the custom status of any user changes. * It's sent via the innerEvent system. */ ON_USER_CUSTOM_STATUS_CHANGE: Contact; /** * @eventProperty ON_CONNECTED_USER__OXEPREFERREDTRUNK_CHANGE * This RB event is sent when OXE PREFERREDTRUNK of connected user changes. * It's sent via the innerEvent system. */ ON_CONNECTED_USER__OXEPREFERREDTRUNK_CHANGE: number; } /** * @internal * @eventProperty * Contact service internal events sent to other sevices via sendInnerEvent() * Should not be used by SDK user */ export declare enum ContactServiceInnerEvents { /** * @eventProperty ON_RAINBOW_ROOM_CONTACT_CREATED * This RB event is sent when a contact of type 'RainbowRoom' (Rainbow TV) is created. * It is sent to the rainbow TV service to link the RB Room/Tv object with the contact. */ ON_RAINBOW_ROOM_CONTACT_CREATED = "ON_RAINBOW_ROOM_CONTACT_CREATED", /** * @eventProperty ON_CONNECTED_USER_SETTINGS_UPDATED * This RB event is sent to detect a change on the user settings custom object. * At the moment it is only used for the 'ringingOnDnd' flag. */ ON_CONNECTED_USER_SETTINGS_UPDATED = "ON_CONNECTED_USER_SETTINGS_UPDATED", /** * @eventProperty ON_MOBILE_TELEPHONY_STATUS_CHANGE * This RBEvent is sent when there's a change in the mobile telephony status. */ ON_MOBILE_TELEPHONY_STATUS_CHANGE = "ON_MOBILE_TELEPHONY_STATUS_CHANGE", /** * @eventProperty ON_CONNECTED_USER_JID_RESOURCE_CHANGE * This RB event is sent when the list of my resources has changed. */ ON_CONNECTED_USER_JID_RESOURCE_CHANGE = "ON_CONNECTED_USER_JID_RESOURCE_CHANGE", /** * @eventProperty ON_CONNECTED_USER_AVATAR_CHANGE * This RBEvent is sent to detect a change on the user'avatar. * Used by Admin only at the moment. */ ON_CONNECTED_USER_AVATAR_CHANGE = "ON_CONNECTED_USER_AVATAR_CHANGE", /** * @eventProperty ON_CONNECTED_USER__OXEPREFERREDTRUNK_CHANGE * This RB event is sent when OXE PREFERREDTRUNK of connected user changes. * It's sent via the innerEvent system. */ ON_CONNECTED_USER__OXEPREFERREDTRUNK_CHANGE = "ON_CONNECTED_USER__OXEPREFERREDTRUNK_CHANGE" } /** * @internal */ export declare class ContactService extends Service implements EventableService { private eventService; private settingsService; private mainService; private logger; private errorHelperService; private authService; private i18nService; private companyService; private xmppService; private networkService; private userService; private readonly rxSubject; private readonly innerRxSubject; private subscriptions; private xmppConnectionSubscription; private presentationModeEventHandlerCleaner; private contactConfigRef; private contactNotifyRef; contacts: Record; dbContacts: Record; jtelContacts: Record; userNetwork?: UserNetworkService; userContact?: ConnectedUserRB; currentLanguage: string; private _displayOrder; private subscriptionPromiseQueue; private getContactPromises; private lastActivityDatePromises; private lastUpdatePresentationMode; private presentationModeTimeout; private apiConfigTTL; private apiConfigTTLTimeout; private presentationModeActive; private awayStateActive; private busyState; manualState: boolean; dndStateActivated: boolean; private getRosterTimeout; static getInstance(): ContactService; static build(): ContactService; private constructor(); start(contactServiceConfig?: any): Promise; stop(): Promise; reconnect(): void; private updateUserContactCompany; private attachHandlers; private onNotifyEvent; private manageSplashScreen; private getApiConfigurationFromServer; private onConnectionStateChangeEvent; /** * Update my fullJid with the new after a reconnection */ private updateUserContactFullJid; private contactPresenceChangedHandler; private onContactChangeEvent; private rosterChangedHandlerPromise; private onUserManagementEvent; private contactCustomStatusChangedHandler; private onPresentationModeChangedEvent; private startUpdatePresentationModeRefreshTimer; /** * Update the user's password * @param oldPassword - The old password * @param newPassword - The new password * @param async - [optional] if TRUE, the resolve of this API will be done once the change is taken into account also on XMPP side; Default value is FALSE */ updateConnectedUserPassword(oldPassword: string, newPassword: string, async?: boolean): Promise; /** * Update the current user avatar * @param base64Image - Base64 image to be uploaded */ setAvatar(base64Image: string): Promise; /** * Remove the current user custom avatar (reset to default avatar) */ removeAvatar(): Promise; setUserSettings(params: any): Promise; /** * Get/Set the user setting for display order of first and last names */ getDisplayOrder(): DisplayOrder; setDisplayOrder(displayOrder: DisplayOrder): void; /** * Checks that an email address is valid. * @param emailAddress - The email address to check */ isEmailAddressValid(emailAddress: string): boolean; /** * Checks that a phone number is valid. * @param phoneNumber - The phone number to check */ isPhoneNumberValid(phoneNumber: string): boolean; /** * Subscribe to updates from the service (all events are of RBEvent type \{name: string, data:any \}); * Here's a list of events received : * name: 'ON_CONTACT_SERVICE_STARTED * NB There might be some events that are not documented here, they're sent on updates of different properties of the contact. * @param handler - The call-back function that will be subscribed to the RxJS subject * @param eventNames - (optional) array of event to listen */ subscribe(handler: (event: RbServiceEvent) => any, eventNames?: MaybeArray): Subscription; subscribeToInnerEvents(handler: any): Subscription; private sendEvent; events(...eventNames: EventNames[]): Observable>>; private sendInnerEvent; private sendContactUpdateEvent; /** * Get all contacts stored for the current user; */ getContacts(): Contact[]; /** * Async method which get a contact. * The contact is first search in service cache then server side. * @param contactRef - a contact jid or contact dbId or contact jid tel */ getContact(contactRef: string): Promise; /** * Get a contact in service cache by his dbId * @param dbId - the dbID of the contact to be found */ getContactFromCacheById(dbId: string): Contact | undefined; /** * Get contact in cache by his jid * @param id - the jid of the contact to be found */ getContactFromCacheByJid(jid: string): Contact; /** * Get a contact by his jid tel * @param jidTel - the jid tel of the contact to be found */ getContactByJidTel(jidTel: string): Contact; /** * Sync method which get a contact. * The contact is searched in service cache * @param contactRef - A contact jid or contact dbId or contact jid tel */ getContactFromCache(contactRef: string): Contact | undefined; getContactById(id: string, server?: boolean): Promise; /** * Get a contact by dbId * If not found, the contact will be searched on server. * @param dbId - the dbId of the contact to be found * @param force - [optional] if TRUE, this will force an update of the contact from the server */ getContactByDBId(dbId: string, force?: boolean): Promise; private getContactByDbIdInner; getContactByJid(jid: string, server?: boolean): Promise; getContactsByJids(jids: string[]): Promise; /** * Get a contact by his email * @param email - the email of the contact to be found */ getContactFromCacheByEmail(email: string): Contact; getContactByEmail(email: string, server?: boolean): Promise; getContactsByEmails(emails: string[]): Promise; getContactInfoByEmail(email: string): Promise; /** * Get a contact by his phonenumber * @param phonenumber - the phonenumber of the contact to be found */ getContactFromCacheByPhoneNumber(phonenumber: string): Contact; /** * Get a contact which contains a phoneNumber from cache * @param phonenumber - the phonenumber of the contact to be found */ getContactFromCacheContainsPhoneNumber(phonenumber: string): Contact; /** * Get a directory contact by his phonenumber * @param phonenumber - the phonenumber of the contact to be found */ getDirectoryContactByPhoneNumber(phonenumber: string): Contact; /** * Get contact by jid or by his phone number; If not found, contact will created and updated from server if possible * @param jid - the jid of the contact to be found * @param phoneNumber - if user has no jid, it could be found by his phone number */ getOrCreateContact(jid: string, phoneNumber?: string): Promise; private createConnectedUser; createContact(): Contact; createBotContact(jid: string, name: string, id: string, botAvatarUrl: string, botCapabilities: any, isRainbowSupportBot: boolean): Contact; createBasicContact(jid: string, phoneNumber?: string, append?: boolean): Contact; createEmptyContact(jid: string): Contact; /** * Create a new directory contact instance (as Contact model). * Used for contact from Business directory / Personal directory / Microsoft Azure Active directory * Usually only Personal directory contacts are stored in the 'contacts' database. * @param id - The id of the new created directory contact * @param storeDb - Flag indicating whether the contact should be stored in the 'contacts' id-key database */ createDirectoryContact(id: string, storeDb?: boolean): Contact; createCallLogContact(phoneNumber: string): Contact; createContactFromData(userData: any): Contact; updateContactFromServer(contact: Contact): Promise; updateContactPersonalRoutines(contactJidIm: string, personalRoutineData: any): void; /** * Update the user's profile data (name, emails, numbers, etc) * Returns the updated user if success and an update on the contact RX is received (or undefined, if the user is not allowed to update his profile) * @param userProfile - The userData to be sent to the server for update * @param checkProfile - when true check if userModification is allowed for this user */ updateUserProfile(userProfile: ConnectedUserProfile & ConnectedUserInit & ConnectedUserMedia, checkProfile?: boolean): Promise; /** * Update the user's custom data (emergencyImSound, enablePushToTalkTone, guideTourDisplayed, etc...) * Returns the updated contact if success and an update on the contact RX is received (or undefined, if the user is not allowed to update his profile) * @param UserCustomData - customData to be sent to the server for update */ updateUserCustomData(customData: UserCustomData): Promise; /** * Update the user's custom status * @param status - status of type {@link UserCustomStatus} to be sent to the server for update */ updateUserCustomStatus(status: UserCustomStatus): Promise; /** * Delete the user's custom status */ deleteUserCustomStatus(): Promise; /** * Delete the account of the connected user. * his API will delete the current user from the server ! BE CAREFUL ! */ deleteConnectedUserAccount(): Promise; /** * Remove a directory contact instance from the 'contacts' cache database. * Warning: The reference must be deleted by the caller, nothing done here ! * Mainly used for personal directory contact management. * @param deletedContact - The directory contact to remove from cache. */ removeDirectoryContactFromCache(deletedContact: Contact): void; /** * Get the contact associated to the connected user. */ getConnectedUser(): User; private refreshUserNetwork; private getNetwork; /** * Returns the list of personal directory contacts defined by the connected user. * The 'PERSONAL_DIRECTORY' feature must be available. */ getPersonnalDirectoryContacts(): Contact[]; searchContacts(criteria: string): Contact[]; /** * Search users in the Rainbow users network (ie 'My Network') of the connected user by using a specified pattern to filter items. * Resolves with an array of contacts and the total number of users matching the criteria. * @param searchPattern - Pattern to search * @param options - Search options */ searchRainbowUsersNetwork(searchPattern: string, options?: DirectorySearchOptions): DirectoryInternalSearchResults; private setUserContactStatus; private calculateContactStatusFromResources; private updatePresence; private updateContactTelephonyStatus; private updateContactIMStatus; private getMissedPresenceMessages; private manageUserSettingsPresenceChange; updateContactRichStatus(contact: Contact, isMe?: boolean): void; sendPresenceFromConfiguration(sendAuthInfo?: boolean): Promise; /** * Return a list of available status that the user can use if he want to change his presence (via changeMyPresence API). * Possible values are ["online", "away", "xa", "dnd"] * Online: User goes to online (or can "exit") any manual state; In case of a call in progress, the user will go to busy state; * Away: Manual Away state * xa: "invisble" or "appear offline" manual state * dnd: Do not disturb manual state */ getConnectedUserAvailablePresenceStatusList(): string[]; setConnectedUserCustomExternalPresence(presenceStatus: UserExternalPresenceStatus, customMessage?: string): Promise; removeConnectedUserCustomExternalPresence(): Promise; /** * Change the current user presence status (if allowed); The status list can be get at all time via computeStatusList * @param status - The presence status that the user wants to set to his user. The status list can be get via computeStatusList API */ setConnectedUserPresence(presenceStatus: UserPresenceStatus | string): void; resetBusyState(): void; setBusyState(status: string, message: string, noUpdate?: boolean): void; /** * Retrieve from the server all the phone numbers associated with a contact. * This is basically done for a USER contact and if these numbers have not already been retrieved. * @param contact - the contact */ retrieveContactPhoneNumbers(contact: Contact): Promise; private getUserSettings; getUserSettingFromSettingsService(settings: string): string; getContactLastActivityDate(contact: Contact): Promise; private updateLastActivity; private updateContactLastActivityDate; /** * Update the user auto dnd calendar settings. If activated, and if the user is sharing with * Rainbow his current calendar (Office 365 or Google Calendar), the presence will automatically go to DND * in case of a meeting scheduled in the calendar. * NB: The user can "exit" the current DND state by simply changing his presence (this will not * deactivate the settings, but will "disable" it for the current meeting, until the next one) * NB: The change of the parameter does not affect the current meeting! It's taken into account for the next one * @param activate - boolean that will activate / deactivate the settings */ updateUserAutoDndCalendarSetting(activate: boolean): Promise; /** * Get the user auto dnd calendar settings. If activated, and if the user is sharing with * Rainbow his current calendar (Office 365 or Google Calendar), the presence will automatically go to DND * in case of a meeting scheduled in the calendar. For more information check updateUserAutoDndCalendarSetting API */ getUserAutoDndCalendarSetting(): boolean; private manageCalendarPresencePrompt; /** * Update the user MS Teams presence calendar settings. If activated, and if the user is sharing with * Rainbow his current calendar (Office 365), the presence from his MS Teams client is managed and the Rainbow application * will go to busy or DND in case the presence in teams change; * @param activate - boolean that will activate / deactivate the settings */ updateUserMSTeamsPresenceSetting(activate: boolean): Promise; /** * Get the user MS Teams presence calendar settings. If activated, and if the user is sharing with * Rainbow his current calendar (Office 365), the presence from his MS Teams client is managed and the Rainbow application * will go to busy or DND in case the presence in his Teams client change; */ getUserMSTeamsPresenceSetting(): boolean; /** * Get the capabilities representing the medias that could be used for a WebRTC Call with the specified remote Rainbow user. */ getConnectedUserWebRTCCallCapabilities(remoteParty: User): WebCallCapabilities; createWebRTCCapabilitiesObservable(remoteParty: User): Observable; notifyImByEmail(contact: Contact): Promise; shouldShowNotification(): boolean; isTelJid(jid: string): boolean; isMediaPillarJid(jid: string): boolean; isUserContact(contact: Contact | User): boolean; isUserContactJid(jid: string): boolean; getResourceFromJid(jid: string): string; getImJid(jid: string): string; isSingleComputerClient(): boolean; myMobileAvailable(): string; contactMatcher(contact: Contact, criteria: string): boolean; } //# sourceMappingURL=contact.service.d.ts.map