import { Contact } from "../common/models/Contact"; import { Appreciation, Channel } from "../common/models/Channel"; import { EventEmitter } from "events"; import { Logger } from "../common/Logger"; import { Core } from "../Core"; import { GenericService } from "./GenericService"; export {}; declare class ChannelsService extends GenericService { private _channels; private _channelsList; MAX_ITEMS: any; MAX_PAYLOAD_SIZE: any; PUBLIC_VISIBILITY: any; PRIVATE_VISIBILITY: any; CLOSED_VISIBILITY: any; private channelEventHandler; private channelHandlerToken; invitationCounter: number; private _contacts; static getClassName(): string; getClassName(): string; static getAccessorName(): string; getAccessorName(): string; LIST_EVENT_TYPE: { ADD: { code: number; label: string; }; UPDATE: { code: number; label: string; }; REMOVE: { code: number; label: string; }; DELETE: { code: number; label: string; }; SUBSCRIBE: { code: number; label: string; }; UNSUBSCRIBE: { code: number; label: string; }; CREATE: { code: number; label: string; }; }; USER_ROLE: { NONE: string; OWNER: string; PUBLISHER: string; MEMBER: 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; /** * @public * @nodered true * @method createChannel * @instance * @async * @category Channels MANAGEMENT * @param {string} name The name of the channel to create (max-length=255) * @param {string} channelTopic The description of the channel to create (max-length=255) * @return {Promise} New Channel * @description * Create a new public channel with a visibility limited to my company
*/ createChannel(name: string, channelTopic: string): Promise; /** * @public * @nodered true * @method createPublicChannel * @instance * @async * @category Channels MANAGEMENT * @param {string} name The name of the channel to create (max-length=255) * @param {string} channelTopic The description of the channel to create (max-length=255) * @param {string} category="" The category of the channel * @return {Promise} New Channel * @description * Create a new public channel with a visibility limited to my company
*/ createPublicChannel(name: string, channelTopic: string, category?: string): Promise; /** * @public * @nodered true * @method createClosedChannel (ex: createPrivateChannel) * @instance * @async * @category Channels MANAGEMENT * @param {string} name The name of the channel to create (max-length=255) * @param {string} description The description of the channel to create (max-length=255) * @param {string} category="" The category of the channel * @return {Promise} New Channel * @description * (old createPrivateChannel) * Create a new closed channel
*/ createClosedChannel(name: string, description: string, category?: string): Promise; /** * @public * @nodered true * @method deleteChannel * @instance * @async * @category Channels MANAGEMENT * @param {Channel} channel The channel to delete * @return {Promise} Promise object represents The channel deleted * @description * Delete an owned channel
*/ deleteChannel(channel: Channel): Promise; /** * @public * @nodered true * @method findChannelsByName * @instance * @async * @category Channels MANAGEMENT * @param {string} name Search this provided substring in the channel name (case insensitive). * @return {Promise>} ChannelsService found * @description * Find channels by name. Only channels with visibility equals to 'company' can be found. First 100 results are returned.
*/ findChannelsByName(name: string): Promise<[Channel]>; /** * @public * @nodered true * @method findChannelsByTopic * @instance * @async * @category Channels MANAGEMENT * @param {string} topic Search this provided substring in the channel topic (case insensitive). * @return {Promise>} ChannelsService found * @description * Find channels by topic. Only channels with visibility equals to 'company' can be found. First 100 results are returned.
*/ findChannelsByTopic(topic: string): Promise<[Channel]>; /** * @private * @method findChannels * @category Channels MANAGEMENT */ private _findChannels; /** * @public * @nodered true * @method fetchChannel * @instance * @async * @category Channels MANAGEMENT * @param {string} id The id of the channel) * @param {boolean} force=false True to force a request to the server * @return {Promise} The channel found * @description * (old getChannelById) * Find a channel by its id (locally if exists or by sending a request to Rainbow)
*/ fetchChannel(id: string, force?: boolean): Promise; /** * @public * @nodered true * @method fetchChannelsByFilter * @since 1.55 * @instance * @category Channels MANAGEMENT * @description * Find channels using a filter (on name, topic)
* Result may be filtered with result limit, offet and sortField or SortOrder
* Return a promise.
* @param {Object} filter The filter with at least [filter.name] or [filter.topic] defined
* {string} [filter.name] search by channel names (case insensitive substring).
* {string} [filter.topic] search by channel topics (case insensitive substring).
* {Number} [filter.limit=100] allow to specify the number of channels to retrieve.
* {Number} [filter.offset] allow to specify the position of first channel to retrieve (first channel if not specified). Warning: if offset > total, no results are returned.
* {string} [filter.sortField="name"] sort channel list based on the given field.
* {Number} [filter.sortOrder="1"] specify order ascending/descending. 1 for ascending, -1 for descending.
* @return {Promise} Result of the find with
* {Array} found channels informations with an array of { id, name, topic, creatorId, visibility, users_count }
*/ fetchChannelsByFilter(filter: any): Promise<[Channel]>; /** * @public * @nodered true * @method fetchMyChannels * @since 1.38 * @instance * @category Channels MANAGEMENT * @param {boolean} force=false Boolean to force the get of channels's informations from server. * @description * (old getChannels) * Get the channels you own, are subscribed to, are publisher
* Return a promise.
* @return {Promise} Return Promise with a list of channels or an empty array if no channel has been found */ fetchMyChannels(force?: boolean): Promise<[Channel]>; /** * @public * @nodered true * @method getAllChannels * @category Channels MANAGEMENT * @instance * @return {Channel[]} An array of channels (owned, invited, subscribed) * @description * Return the list of channels (owned, invited, subscribed)
*/ getAllChannels(): [Channel]; /** * @public * @nodered true * @method getAllOwnedChannels * @category Channels MANAGEMENT * @instance * @return {Channel[]} An array of channels (owned only) * @description * (old getAllOwnedChannel) * Return the list of owned channels only
*/ getAllOwnedChannels(): [Channel]; /** * @public * @nodered true * @method getAllPendingChannels * @category Channels MANAGEMENT * @instance * @return {Channel[]} An array of channels (invited only) * @description * Return the list of invited channels only
*/ getAllPendingChannels(): [Channel]; /** * @public * @nodered true * @method updateChannelTopic * @instance * @async * @category Channels MANAGEMENT * @param {Channel} channel The channel to update * @param {string} description The description of the channel to update (max-length=255) * @return {Promise} Updated channel * @description * Update the description of a channel.
*/ updateChannelTopic(channel: Channel, description: string): Promise; /** * @public * @nodered true * @method updateChannelDescription * @instance * @async * @category Channels MANAGEMENT * @param {Channel} channel The channel to update * @param {string} description The description of the channel to update (max-length=255) * @return {Promise} Updated channel * @description * Update the description of a channel.
* */ updateChannelDescription(channel: Channel, description: string): Promise; /** * @public * @nodered true * @method updateChannelName * @since 1.46 * @instance * @category Channels MANAGEMENT * @description * Update a channel name
* Return a promise.
* @param {Channel} channel The channel to update * @param {string} channelName The name of the channel * @return {Channel} Return the channel updated or an error */ updateChannelName(channel: Channel, channelName: string): Promise; /** * @public * @nodered true * @method updateChannel * @since 1.38 * @category Channels MANAGEMENT * @instance * @description * Update a channel
* May be updated: name, topic, visibility, max_items and max_payload
* Please put null to not update a property.
* Return a promise.
* @param {string} id The id of the channel * @param {string} channelTopic The topic of the channel * @param {string} visibility=public public/company/closed group visibility for search * @param {Number} max_items=30 max # of items to persist in the channel * @param {Number} max_payload_size=60000 max # of items to persist in the channel * @param {string} channelName The name of the channel * @param {string} category The category of the channel * @return {Promise} Return the channel created or an error */ updateChannel(id: string, channelTopic?: string, visibility?: string, max_items?: Number, max_payload_size?: Number, channelName?: string, category?: string): Promise; /** * @public * @nodered true * @method updateChannelVisibility * @since 1.55 * @category Channels MANAGEMENT * @instance * @description * Update a channel visibility
* Return a promise.
* @param {Channel} channel The channel to update * @param {string} visibility The new channel visibility (closed or company) * @return {Promise} Return the channel updated or an error */ updateChannelVisibility(channel: Channel, visibility: string): Promise; /** * @public * @nodered true * @method updateChannelVisibilityToPublic * @since 1.55 * @category Channels MANAGEMENT * @instance * @description * Set the channel visibility to company (visible for users in that company)
* Return a promise.
* @param {Channel} channel The channel to update * @return {Channel} Return the channel updated or an error */ updateChannelVisibilityToPublic(channel: Channel): Promise; /** * @public * @nodered true * @method updateChannelVisibilityToClosed * @since 1.55 * @instance * @category Channels MANAGEMENT * @description * Set the channel visibility to closed (not visible by users)
* Return a promise.
* @param {Channel} channel The channel to update * @return {Channel} Return the channel updated or an error */ updateChannelVisibilityToClosed(channel: Channel): Promise; /** * @public * @nodered true * @method updateChannelAvatar * @since 1.43 * @instance * @category Channels MANAGEMENT * @description * Update a channel avatar
* Return a promise.
* @param {Channel} channel The Channel to update * @param {string} urlAvatar The avatar Url. It must be resized to 512 pixels before calling this API. * @return {Channel} Return the channel updated or an error */ updateChannelAvatar(channel: Channel, urlAvatar: string): Promise; /** * @public * @nodered true * @method deleteChannelAvatar * @since 1.43 * @instance * @category Channels MANAGEMENT * @description * Delete a channel avatar
* Return a promise.
* @param {Channel} channel The channel to update * @return {Channel} Return the channel updated or an error */ deleteChannelAvatar(channel: Channel): Promise; /** * @private * @param channelId * @category Channels MANAGEMENT * @description * GET A CHANNEL
*/ getChannel(channelId: string): Promise; /** * @private * @param channelId * @category Channels MANAGEMENT * @description * GET A CHANNEL FROM CACHE
*/ private getChannelFromCache; private updateChannelsList; private addOrUpdateChannelToCache; private removeChannelFromCache; /** * @public * @nodered true * @method publishMessageToChannel * @instance * @async * @category Channels MESSAGES/ITEMS * @param {Channel} channel The channel where to publish the message * @param {string} message Message content * @param {string} title Message title, limit=256. * @param {string} url An URL * @param {any} imagesIds=null An Array of ids of the files stored in Rainbow * @param {string} type="basic" An optional message content type (could be basic, markdown, html or data) * @param {Object} customDatas={} A JSON object with custom datas merged to the payload send to server. * @return {Promise} OK if successfull * @description * Publish to a channel
*/ publishMessageToChannel(channel: Channel, message: string, title?: string, url?: string, imagesIds?: any, type?: string, customDatas?: any): Promise<{}>; /** * @public * @method createItem * @instance * @async * @category Channels MESSAGES/ITEMS * @param {Channel} channel The channel where to publish the message * @param {string} message Message content * @param {string} title="" Message title, limit=256. * @param {string} url="" An URL * @param {any} imagesIds An Array of ids of the files stored in Rainbow * @param {string} type="basic" An optional message content type (could be basic, markdown, html or data) * @param {Object} customDatas={} A JSON object with custom datas merged to the payload send to server. * @return {Promise} OK if successfull * @description * Publish to a channel
*/ createItem(channel: Channel, message: string, title: string, url: string, imagesIds: any, type?: string, customDatas?: any): Promise<{}>; /** * @public * @nodered true * @method fetchChannelItems * @instance * @async * @category Channels MESSAGES/ITEMS * @param {Channel} channel The channel * @param {number} maxMessages=100 [optional] number of messages to get, 100 by default * @param {Date} beforeDate [optional] - show items before a specific timestamp (ISO 8601 format) * @param {Date} afterDate [optional] - show items after a specific timestamp (ISO 8601 format) * @return {Promise} The list of messages received * @description * (old getChannels) * Retrieve the last maxMessages messages from a channel
*/ fetchChannelItems(channel: Channel, maxMessages?: number, beforeDate?: Date, afterDate?: Date): Promise>; /** * @public * @nodered true * @method deleteItemFromChannel * @instance * @async * @category Channels MESSAGES/ITEMS * @param {string} channelId The Id of the channel * @param {string} itemId The Id of the item * @return {Promise} The channel updated * @description * (old deleteMessageFromChannel) * Delete a message from a channel
*/ deleteItemFromChannel(channelId: string, itemId: string): Promise; /** * @public * @nodered true * @method likeItem * @instance * @async * @category Channels MESSAGES/ITEMS * @param {Channel} channel The channel where the item must be liked. * @param {string} itemId The Id of the item * @param {Appreciation} appreciation Appreciation value - must be one of the value specified in Appreciation object. * @return {Promise} * @description * To like a Channel Item with the specified appreciation
*/ likeItem(channel: Channel, itemId: string, appreciation: Appreciation): Promise; /** * @public * @nodered true * @method getDetailedAppreciations * @instance * @async * @category Channels MESSAGES/ITEMS * @param {Channel} channel The channel where the item appreciations must be retrieved. * @param {string} itemId The Id of the item * @return {Promise} * @description * To know in details apprecations given on a channel item (by userId the apprecation given)
*/ getDetailedAppreciations(channel: Channel, itemId: string): Promise; retrieveLatests(beforeDate?: Date): Promise; /** * @public * @nodered true * @method getAllSubscribedChannels * @instance * @category Channels SUBSCRIPTION * @return {Channel[]} An array of channels (subscribed only) * @description * (old getAllSubscribedChannel) * Return the list of subscribed channels only
*/ getAllSubscribedChannels(): [Channel]; /** * @public * @nodered true * @method subscribeToChannel * @instance * @async * @category Channels SUBSCRIPTION * @param {Channel} channel The channel to subscribe * @return {Promise} The channel updated with the new subscription * @description * Subscribe to a public channel
*/ subscribeToChannel(channel: Channel): Promise; /** * @public * @nodered true * @method subscribeToChannelById * @since 1.47 * @instance * @category Channels SUBSCRIPTION * @description * Subscribe to a channel using its id
* Return a promise.
* @param {string} id The id of the channel * @return {Object} Nothing or an error object depending on the result */ subscribeToChannelById(id: string): Promise; /** * @public * @nodered true * @method unsubscribeFromChannel * @instance * @async * @category Channels SUBSCRIPTION * @param {Channel} channel The channel to unsubscribe * @return {Promise} The status of the unsubscribe. * @description * Unsubscribe from a public channel
*/ unsubscribeFromChannel(channel: Channel): Promise; /** * @public * @nodered true * @method fetchChannelUsers * @instance * @async * @category Channels USERS * @param {Channel} channel The channel * @param {Object} options A filter parameter * @param {Number} options.page=0 Display a specific page of results * @param {Number} options.limit=100 Number of results per page (max 1000) * @param {Boolean} options.onlyPublishers=false Filter to publishers only * @param {Boolean} options.onlyOwners=false Filter to owners only * @return {Promise>} An array of users who belong to this channel * @description * (old getUsersFromChannel) * Get a pagined list of users who belongs to a channel
*/ fetchChannelUsers(channel: Channel, options: any): Promise>; /** * @public * @nodered true * @method deleteAllUsersFromChannel * @instance * @async * @category Channels USERS * @param {Channel} channel The channel * @return {Promise} The channel updated * @description * (old removeAllUsersFromChannel) * Remove all users from a channel
*/ deleteAllUsersFromChannel(channel: Channel): Promise; /** * @public * @nodered true * @method updateChannelUsers * @instance * @async * @category Channels USERS * @param {Channel} channel The channel * @param {Array} users The users of the channel. * collection of users to update * [ * { * id : string, // Rainbow user Id * type : string // user channel affiliation. Possibles values : none, owner, publisher, member * } * ] * * @return {Promise} Update Channel Users status * @description * Update a collection of channel users */ updateChannelUsers(channel: Channel, users: Array): Promise; /** * @public * @nodered true * @method updateChannelUsersByLoginEmails * @instance * @since 2.23.0 * @async * @category Channels USERS * @param {Channel} channel The channel * @param {Array} users Array of users loginEmail of the channel. * collection of users to update * [ * { * loginEmail : string, // Rainbow user loginEmail. * type : string // user channel affiliation. Possibles values : none, owner, publisher, member * } * ] * * @return {Promise} Update Channel Users status * @description * Update a collection of channel users by loginEmail * */ updateChannelUsersByLoginEmails(channel: Channel, users: Array): Promise; /** * @public * @nodered true * @method addOwnersToChannel * @instance * @async * @category Channels USERS * @param {Channel} channel The channel * @param {Array}owners Array of owners to add. * @return {Promise} The updated channel * @description * Add a list of owners to the channel
*/ addOwnersToChannel(channel: Channel, owners: any[]): Promise; /** * @public * @nodered true * @method addOwnersToChannelByLoginEmails * @instance * @async * @category Channels USERS * @param {Channel} channel The channel * @param {Array} owners Array of loginEmail of owners. * collection of owners loginEmails * [ * { * loginEmail : string, // Rainbow user loginEmail. * } * ] * * @return {Promise} The updated channel * @description * Add a list of owners to the channel by loginEmail
* */ addOwnersToChannelByLoginEmails(channel: Channel, owners: any[]): Promise; /** * @public * @nodered true * @method addPublishersToChannel * @instance * @async * @category Channels USERS * @param {Channel} channel The channel * @param {Array} publishers The list of Contacts to add as publisher to channel. * @return {Promise} The updated channel * @description * Add a list of publishers to the channel
* */ addPublishersToChannel(channel: Channel, publishers: Array): Promise; /** * @public * @nodered true * @method addPublishersToChannelByLoginEmails * @instance * @async * @category Channels USERS * @param {Channel} channel The channel * @param {Array} publishers The list of Contacts loginEmails to add as publisher to channel. * collection of owners loginEmails * [ * { * loginEmail : string, // Rainbow user loginEmail. * } * ] * * @return {Promise} The updated channel * @description * Add a list of publishers to the channel by loginEmail
* */ addPublishersToChannelByLoginEmails(channel: Channel, publishers: Array): Promise; /** * @public * @nodered true * @method addMembersToChannel * @instance * @async * @category Channels USERS * @param {Channel} channel The channel * @param {Array} members array of users to add * @return {Promise} The updated channel * @description * Add a list of members to the channel by loginEmail
*/ addMembersToChannel(channel: Channel, members: Array): Promise; /** * @public * @nodered true * @method addMembersToChannelByLoginEmails * @instance * @async * @category Channels USERS * @param {Channel} channel The channel * @param {Array} members array of users loginEmail to add * collection of owners loginEmails * [ * { * loginEmail : string, // Rainbow user loginEmail. * } * ] * * @return {Promise} The updated channel * @description * Add a list of members to the channel by loginEmail
* */ addMembersToChannelByLoginEmails(channel: Channel, members: Array): Promise; /** * @public * @nodered true * @method deleteUsersFromChannel * @instance * @async * @category Channels USERS * @param {Channel} channel The channel * @param {Array} users An array of users to remove * @return {Promise} The updated channel * @description * (old removeUsersFromChannel1) * Remove a list of users from a channel
*/ deleteUsersFromChannel(channel: Channel, users: Array): Promise; /** * @public * @nodered true * @method deleteUsersFromChannelByLoginEmails * @instance * @async * @category Channels USERS * @param {Channel} channel The channel * @param {Array} users An array of loginEmail of users to remove * collection of owners loginEmails * [ * { * loginEmail : string, // Rainbow user loginEmail. * } * ] * * @return {Promise} The updated channel * @description * (old removeUsersFromChannel1) * Remove a list of users from a channel by loginEmail
* */ deleteUsersFromChannelByLoginEmails(channel: Channel, users: Array): Promise; _onChannelMessageReceived(message: any): void; _onChannelMyAppreciationReceived(my_appreciation: any): void; /****************************************************************/ /*** MANAGEMENT EVENT HANDLER ***/ /****************************************************************/ private onAvatarChange; private onUpdateToChannel; onAddToChannel(channelInfo: { id: string; }): void; private onRemovedFromChannel; private onSubscribeToChannel; private onUnsubscribeToChannel; private onDeleteChannel; private onUserSubscribeEvent; private onUserUnsubscribeEvent; /****************************************************************/ /*** END MANAGEMENT EVENT HANDLER ***/ /****************************************************************/ incrementInvitationCounter(): void; decrementInvitationCounter(): void; } export { ChannelsService as ChannelsService };