import { Logger } from "../common/Logger"; import { EventEmitter } from "events"; import { Core } from "../Core"; import { PresenceLevel, PresenceRainbow } from "../common/models/PresenceRainbow"; import { GenericService } from "./GenericService"; import { Bubble } from "../common/models/Bubble"; import { CalendarManager } from "../common/CalendarManager.js"; import { AutoReplyManager } from "../common/AutoReplyManager.js"; export {}; declare class PresenceService extends GenericService { private _settings; private _presenceEventHandler; private _presenceHandlerToken; private manualState; private _currentPresence; RAINBOW_PRESENCE_ONLINE: PresenceLevel.Online; RAINBOW_PRESENCE_DONOTDISTURB: PresenceLevel.Dnd; RAINBOW_PRESENCE_AWAY: PresenceLevel.Away; RAINBOW_PRESENCE_INVISIBLE: PresenceLevel.Invisible; private _bubbles; static getClassName(): string; getClassName(): string; static getAccessorName(): string; getAccessorName(): string; constructor(_core: Core, _eventEmitter: EventEmitter, _logger: Logger, _startConfig: { start_up: boolean; optional: boolean; }); start(_options: any): Promise; stop(): Promise; init(useRestAtStartup: boolean): Promise; attachHandlers(): void; /** * @private * @method sendInitialPresence * @instance * @async * @category Presence CONNECTED USER * @description * Send the initial presence (online)
* @return {Promise} A promise containing the result */ sendInitialPresence(): Promise; /** * @public * @nodered true * @method setPresenceTo * @instance * @async * @category Presence CONNECTED USER * @description * Allow to change the presence of the connected user
* Only the following values are authorized: 'dnd', 'away', 'invisible' or 'online'
* @param {String} presence The presence value to set i.e: 'dnd', 'away', 'invisible' ('xa' on server side) or 'online' * @return {Promise} * @fulfil {ErrorManager} - ErrorManager object depending on the result (ErrorManager.getErrorManager().OK in case of success) */ setPresenceTo(presence: PresenceLevel): Promise; /** * @public * @nodered true * @method getUserConnectedPresence * @instance * @category Presence CONNECTED USER * @description * Get user presence status calculated from events.
*/ getUserConnectedPresence(): PresenceRainbow; /** * @private * @method _setUserPresenceStatus * @instance * @async * @category Presence CONNECTED USER * @description * Send user presence status and message to xmpp.
*/ _setUserPresenceStatus(presenceRainbow: PresenceRainbow): Promise; /** * @private * @method _sendPresenceFromConfiguration * @instance * @async * @category Presence CONNECTED USER * @description * Send user presence according to user settings presence.
*/ _sendPresenceFromConfiguration(useRestAtStartup: any): Promise; /** * @public * @nodered true * @method getMyPresenceInformation * @since 2.16.0 * @instance * @category Presence CONNECTED USER * @description * Get user's resources presences information from server.
*/ getMyPresenceInformation(): Promise; /** * @public * @nodered true * @method setApplyMsTeamsPresenceSettings * @instance * @async * @category Presence CONNECTED USER * @description * Allow to activate the exchange of presence of the connected user between rainbow and MS Teams on UI side.
* @param {boolean} connectTeams=false The boolean to activate or not the feature. * @return {Promise} */ setApplyMsTeamsPresenceSettings(connectTeams?: boolean): Promise; /** * @private * @method sendInitialAllBubblePresence * @instance * @async * @category Presence Bubbles * @param {boolean} webinar=false should option webinar be setted. * @param {boolean} acknowledge=true should option acknowledge should be setted. * @description * Method called to sen presence to all bubbles
*/ sendInitialAllBubblePresence(webinar?: boolean, acknowledge?: boolean): Promise; /** * @private * @method sendInitialBubblePresenceSync * @instance * @async * @category Presence Bubbles * @param {Bubble} bubble The Bubble * @param {number} intervalDelay=7500 The interval between sending presence to a Bubble while it failed. default value is 75000 ms. * @description * Method called when receiving an invitation to join a bubble
*/ sendInitialBubblePresenceSync(bubble: Bubble, intervalDelay?: number): Promise; /** * @private * @method sendInitialBubblePresenceById * @instance * @async * @category Presence Bubbles * @param {string} id The Bubble id. * @param {number} attempt=0 To log a number of attempt of sending presence to the Bubble. default value is 0. * @description * Method called when receiving an invitation to join a bubble
*/ sendInitialBubblePresenceById(id: string, attempt?: number): Promise; /** * @private * @method sendInitialBubblePresence * @instance * @async * @category Presence Bubbles * @param {Bubble} bubble The Bubble * @param {number} attempt=0 To log a number of attempt of sending presence to the Bubble. default value is 0. * @description * Method called when receiving an invitation to join a bubble
*/ sendInitialBubblePresence(bubble: Bubble, attempt?: number): Promise; /** * @private * @method sendInitialBubblePresenceSyncFn * @instance * @async * @category Presence Bubbles * @param {Bubble} bubble The Bubble * @param {number} intervalDelay=7500 The interval between sending presence to a Bubble while it failed. default value is 75000 ms. * @description * Method called when receiving an invitation to join a bubble
*/ sendInitialBubblePresenceSyncFn(bubble: Bubble, intervalDelay?: number): Promise; /** * @private * @method _onUserSettingsChanged * @instance * @description * Method called when receiving an update on user settings
*/ _onUserSettingsChanged(): void; /** * @private * @method _onPresenceChanged * @instance * @description * Method called when receiving an update on user presence
*/ _onMyPresenceChanged(user: any): void; _onEWSgeteventsReceived(data: any): void; _onEWSgetautoreplyReceived(data: any): void; /** * @public * @nodered true * @method getCalendarState * @instance * @category Presence CALENDAR * @description * Allow to get the calendar presence of the connected user
* return promise with {
* busy: boolean, // Does the connected user is busy ?
* status: string, // The status of the connected user (one of "free", "busy" or "out_of_office")
* subject: string, // The meeting subject.
* since: string, // The meeting since date.
* until: string // Date until the current presence is valid
* }
*
* Note : "applyCalendarPresence" boolean is not return by this api, so you can not know if the presence should be used in general calculated presence.
* @async * @return {Promise<{ * busy: boolean, * status: string, * subject: string, * since: string, * until: string * }, ErrorManager>} * @fulfil {ErrorManager} - ErrorManager object depending on the result. */ getCalendarState(): Promise; /** * @public * @nodered true * @method getCalendarStates * @instance * @category Presence CALENDAR * @param {Array} users The list of the Rainbow user's references - id or logins (Contact::loginEmail) - to retrieve the calendar presence. * @description * Allow to get the calendar presence of severals users
* return promise with { * usersIdentifier : { // List of calendar user states.
* busy: boolean, // Does the connected user is busy ?
* status: string, // The status of the connected user (one of "free", "busy" or "out_of_office")
* subject: string, // The meeting subject.
* since: string, // The meeting since date.
* until: string // Date until the current presence is valid
* }
*
* Note : "applyCalendarPresence" boolean is not return by this api, so you can not know if the presence should be used in general calculated presence.
* @async * @return {Promise< { * busy: boolean, * status: string, * subject: string, * since: string, * until: string * }, ErrorManager>} * @fulfil {ErrorManager} - ErrorManager object depending on the result. */ getCalendarStates(users?: Array): Promise; /** * @public * @nodered true * @method setCalendarRegister * @instance * @category Presence CALENDAR * @param {string} type Calendar type. Default : office365, Authorized values : office365, google * @param {boolean} redirect Immediately redirect to login page (OAuth2) or generate an HTML page. Default : false. * @param {string} callback Redirect URL to the requesting client. * @description * Register a new calendar.
* return promise with { * "url" : string // Calendar provider's OAuth URL
* }
* @async * @return {Promise<{ * "url" : string * }, ErrorManager>} * @fulfil {ErrorManager} - ErrorManager object depending on the result. */ setCalendarRegister(type?: string, redirect?: boolean, callbackUrl?: string): Promise; /** * @public * @nodered true * @method getCalendarAutomaticReplyStatus * @instance * @category Presence CALENDAR * @param {string} userId The id of user to retrieve the calendar automatic reply status. * @description * Allow to retrieve the calendar automatic reply status
* return promise with {
* enabled : string, // its status
* start : string, // its start date
* end : string, // its end date
* message_text : string, // its message as plain text
* message_thtml : string // its message as html
* }
*
* @async * @return {Promise<{ * enabled : string, * status : string, * start : string, * end : string, * message_text : string, * message_thtml : string * }, ErrorManager>} * @fulfil {ErrorManager} - ErrorManager object depending on the result. */ getCalendarAutomaticReplyStatus(userId?: string): Promise; /** * @private * @method enableCalendar * @instance * @category Presence CALENDAR * @deprecated * @description * Allow to enable the calendar.
* return promise with {
* Status : string // Operation status ("enabled" or "disabled")
* }
*
* @async * @return {Promise< { * Status : string * }, ErrorManager>} * @fulfil {ErrorManager} - ErrorManager object depending on the result. */ /** * @private * @method disableCalendar * @instance * @category Presence CALENDAR * @deprecated * @description * Allow to disable the calendar.
* return promise with {
* Status : string // Operation status ("enabled" or "disabled")
* }
*
* @async * @return {Promise< { * Status : string * }, ErrorManager>} * @fulfil {ErrorManager} - ErrorManager object depending on the result. */ /** * @public * @nodered true * @method controlCalendarOrIgnoreAnEntry * @instance * @category Presence CALENDAR * @param {boolean} disable disable calendar, true to re-enable * @param {string} ignore ignore the current calendar entry, false resumes the entry. Possible values : current, false * @description * Enable/disable a calendar sharing or ignore a calendar entry.
* return promise with {
* Status : string // Operation status ("enabled" or "disabled")
* }
*
* @async * @return {Promise< { * Status : string * }, ErrorManager>} * @fulfil {ErrorManager} - ErrorManager object depending on the result. */ controlCalendarOrIgnoreAnEntry(disable?: boolean, ignore?: string): Promise; /** * @public * @nodered true * @method unregisterCalendar * @instance * @category Presence CALENDAR * @description * Delete a calendar sharing.
* return promise with {
* Status : string // Operation status ("deleted")
* }
*
* @async * @return {Promise< { * Status : string * }, ErrorManager>} * @fulfil {ErrorManager} - ErrorManager object depending on the result. */ unregisterCalendar(): Promise; /** * @public * @nodered true * @method controlMsteamsPresence * @since 2.20.0 * @instance * @category Manage Presence MSTeams * @param {boolean} disable disable presence, true to re-enable * @param {string} ignore ignore the current rainbow presence sharing * @async * @description * Enable/disable a presence sharing or ignore rainbow presence sharing.
* When disabled or enabled, a message stanza is sent to the user for multi-devices constraints.
* @return {Promise} */ controlMsteamsPresence(disable?: boolean, ignore?: string): Promise; /** * @public * @nodered true * @method getMsteamsPresenceState * @since 2.20.0 * @instance * @category Manage Presence MSTeams * @param {string} userId The Rainbow user id, his jid or the email of his attached Microsoft teams presence. Default value is the current connected user's id * @async * @description * Get a MS-teams presence state
* @return {Promise}

* * enabled * ------- * * | Champ | Type | Description | * | --- | --- | --- | * | busy | Boolean | presence busy flag. | * | status | String | presence status (one of "chat", "busy" or "dnd") | * * disabled * -------- * * | Champ | Type | Description | * | --- | --- | --- | * | status | String | presence sharing is disabled (status = 'disabled') | * * subscription_error * ------------------ * * | Champ | Type | Description | * | --- | --- | --- | * | status | String | presence sharing with a expired subscription | * * none * ---- * * | Champ | Type | Description | * | --- | --- | --- | * | status | String | presence sharing is not defined (status = 'none') | * * * */ getMsteamsPresenceState(userId?: string): Promise; /** * @public * @nodered true * @method getMsteamsPresenceStates * @since 2.20.0 * @instance * @category Manage Presence MSTeams * @param {Array} users The Rainbow user references (can be email or id). Default value is an Array with the current connected user's id. * @async * @description * Get a MS-teams presence states of several users
* @return {Promise}

* * enabled * ------- * * | Champ | Type | Description | * | --- | --- | --- | * | users | Object\[\] | list of presence user states. | * | busy | Boolean | presence busy flag. | * | status | String | presence status (one of "chat", "busy" or "dnd"). | * * others * ------ * * | Champ | Type | Description | * | --- | --- | --- | * | users | Object\[\] | list of presence user states. | * | status | String | presence status (one of "disabled", "subscription_error", "none"). | * */ getMsteamsPresenceStates(users?: Array): Promise; /** * @public * @nodered true * @method registerMsteamsPresenceSharing * @since 2.20.0 * @instance * @category Manage Presence MSTeams * @param {boolean} redirect Immediately redirect to login page (OAuth2) or generate an HTML page. * @param {string} callback Redirect URL to the requesting client. * @async * @description * The requesting client get a redirection URL or could be redirected immediately to the provider login page to gather user consent.
* @return {Promise}

* * | Champ | Type | Description | * | --- | --- | --- | * | url | String | Microsoft Teams Presence OAuth URL | * * */ registerMsteamsPresenceSharing(redirect?: boolean, callback?: string): Promise; /** * @public * @nodered true * @method unregisterMsteamsPresenceSharing * @since 2.20.0 * @instance * @category Manage Presence MSTeams * @async * @description * Delete a MS Teams presence sharing.
* A message stanza is sent to the user for multi-devices constraints.
* @return {Promise}

* * | Champ | Type | Description | * | --- | --- | --- | * | Status | String | Operation status | * * */ unregisterMsteamsPresenceSharing(): Promise; /** * @public * @nodered true * @method activateMsteamsPresence * @since 2.20.0 * @instance * @category Manage Presence MSTeams * @async * @description * activate a MS Teams presence sharing.
* A message stanza is sent to the user for multi-devices constraints.
* @return {Promise}

* * | Champ | Type | Description | * | --- | --- | --- | * | Status | String | Operation status | * * */ activateMsteamsPresence(): Promise; /** * @public * @nodered true * @method deactivateMsteamsPresence * @since 2.20.0 * @instance * @category Manage Presence MSTeams * @async * @description * desactivate a MS Teams presence sharing.
* A message stanza is sent to the user for multi-devices constraints.
* @return {Promise}

* * | Champ | Type | Description | * | --- | --- | --- | * | Status | String | Operation status | * * */ deactivateMsteamsPresence(): Promise; /** * @private * @method subscribePresence * @instance * @category Presence Contact * @description * Allows to subscribe presence to a contact.
* @async * @return {Promise< any, ErrorManager>} * @fulfil {ErrorManager} - ErrorManager object depending on the result. */ subscribePresence(to: any): Promise; /** * @public * @method notifyCalendarProvider * @instance * @category Presence Contact * @async * @description * Allows to subscribe users to EWS using a webhook in Rainbow.
* EWS cnx opens an event session for each subscribed user.
* EWS cnx notify to Rainbow each new appointment changes.
* * For each event, a IQ GetEvent request will be sent to retrieve a potential event that will occur in current time frame window. * @param {Array} ids The ids specified in field value of body request are the Rainbow user id for which a new calendar event has been created. * @param {Object} headers Allow to define specifics headers to the request. * @param {boolean} forceNotify Allow to to force the refresh of xmpp status as a comparaison is done between old and new presence status. * @return {Promise< any, ErrorManager>} * @fulfil {ErrorManager} - ErrorManager object depending on the result. */ notifyCalendarProvider(ids: Array, headers?: any, forceNotify?: boolean): Promise; /** * @public * @method sendResultCalendarEvents * @instance * @category Presence Contact * @async * @description * Allows to send result of a get events iq request from Rainbow.
* * Note: To be used when a "rainbow_onEWSgetevents" event is received to send events response. * * @example * * rainbowSDK.events.on("rainbow_onEWSgetevents", (data) => { * _logger.log("debug", "MAIN - (rainbow_onEWSgetevents) - rainbow event received.", data); * let calendarManager = new RainbowSDK.CalendarManager(data.id, data.from, data.email); * calendarManager.addEvent( * { * "id": "evt-001", * "subject": "Réunion projet", * "type": "singleInstance", * "showAs": "busy", * startDate: { * "value": "2025-08-14T09:00:00Z", * "timezone": "Europe/Paris" * }, * "endDate": { * "value": "2025-08-14T10:30:00Z", * timezone: "Europe/Paris" * } * }); * calendarManager.addEvent( * { * "id": "evt-002", * "subject": "Pause café", * "type": "occurrence", * "showAs": "free", * "startDate": { * "value": "2025-08-14T10:30:00Z" * }, * "endDate": { * "value": "2025-08-14T10:45:00Z" * } * }); * * rainbowSDK.presence.sendResultCalendarEvents(calendarManager); * }); * * @param {CalendarManager} calendarManager Allow to define the result of a get events iq request from Rainbow. * @return {Promise< any, ErrorManager>} * @fulfil {ErrorManager} - ErrorManager object depending on the result. */ sendResultCalendarEvents(calendarManager: CalendarManager): Promise; /** * @public * @method sendAutoReplyEvents * @instance * @category Presence Contact * @async * @description * Allows to send result of a get auto reply events iq request from Rainbow.
* * Note: To be used when a "rainbow_onEWSgetevents" event is received to send events response. * * @example * * rainbowSDK.events.on("rainbow_onEWSgetautoreply", (data) => { * _logger.log("debug", "MAIN - (rainbow_onEWSgetautoreply) - rainbow event received.", data); * * let autoReplyManager = new RainbowSDK.AutoReplyManager({ * id: data.id, * to: data.from, * state: "scheduled", * email: data.email, * startDate: { value: "2025-08-20T09:00:00Z", timezone: "Europe/Paris" }, * endDate: { value: "2025-08-25T18:00:00Z", timezone: "Europe/Paris" }, * internalReplyMessage: "Je suis absent du bureau, merci de contacter mon collègue.", * externalReplyMessage: { * value: "Je suis actuellement en congés.", * audience: "known" * } * }); * * rainbowSDK.presence.sendAutoReplyEvents(autoReplyManager); * }); * @param {AutoReplyManager} autoReplyManager Allow to define get auto reply events iq. * @return {Promise< any, ErrorManager>} * @fulfil {ErrorManager} - ErrorManager object depending on the result. */ sendAutoReplyEvents(autoReplyManager: AutoReplyManager): Promise; } export { PresenceService };