/** * @module Channels */ import { Subscription } from "rxjs"; import { Channel, ChannelAggregated, ChannelRB, ChannelConfidentiality, ChannelGetUsersOptions, ChannelSearchUsersOptions, ChannelSettings, ChannelUser, ChannelUserRole, ChannelVisibility } from '../../models/channel.model'; import { ChannelMessage, ChannelPost, ChannelPostReaction, ChannelPostUserReactions } from '../../models/channelMessage.model'; import { RBEvent } from '../../models/event.model'; import { Service } from "../../services/service"; import { StropheHandler } from "../../libs/strophe/types"; /** * @internal */ export declare const CHANNEL_SVC = "ChannelService"; /** * @eventProperty * This enum lists all the `RBEvent` events generated by the Channel service. * They can be listened to using the `channelService.subscribe()` API. */ export declare enum ChannelServiceEvents { /** * @eventProperty * This `RBEvent` is send when the channel service is started and ready to be used (also fired after loss of network and reconnection) */ ON_SERVICE_STARTED = "ON_SERVICE_STARTED", /** * @eventProperty * This RBEvent is sent when the connected user has received an invitation to susbcribe to a channel. * At the end of the process, the user will be added in the channel. * **Event Data** * - **channel**: The channel for which the invitation was sent. */ ON_CONNECTED_USER_INVITATION_RECEIVED = "ON_CONNECTED_USER_INVITATION_RECEIVED", /** * @eventProperty * This RBEvent is sent when the connected user has declined an invitation to join a channel. * At the end of the process, the user will be removed from the channel. * **Event Data** * - **channel**: The channel for which the invitation was sent. */ ON_CONNECTED_USER_INVITATION_DECLINED = "ON_CONNECTED_USER_INVITATION_DECLINED", /** * @eventProperty * This RBEvent is sent when the connected user has accepted an invitation to join a channel. * **Event Data** * - **channel**: The channel for which the invitation was sent. */ ON_CONNECTED_USER_INVITATION_ACCEPTED = "ON_CONNECTED_USER_INVITATION_ACCEPTED", /** * @eventProperty * This `RBEvent` event is sent when the connected user has subscribed to a channel. * **Event Data** * - **channel**: The channel concerned. */ ON_USER_SUBSCRIPTION = "ON_USER_SUBSCRIPTION", /** * @eventProperty * This RBEvent is sent when the connected user has added to the channel. * **Event Data** * - **channel**: The channel concerned by this event */ ON_CONNECTED_USER_ADDED = "ON_CONNECTED_USER_ADDED", /** * @eventProperty * This RBEvent is sent when the role of a member channel has changed. * **Event Data** * - **channel**: The channel concerned by this event */ ON_USER_ROLE_UPDATED = "ON_USER_ROLE_UPDATED", /** * @eventProperty * This `RBEvent` event is sent when a new post has been published in the channel. * **Event Data** * - **channel**: The channel in which the new post has been published. * - **post**: The new published post. */ ON_CHANNEL_POST_PUBLISHED = "ON_CHANNEL_POST_PUBLISHED", /** * @eventProperty * This `RBEvent` event is sent when a post already published in the channel has been modified. * **Event Data** * - **channel**: The channel in which the post has been modified. * - **post**: The updated post. */ ON_CHANNEL_POST_UPDATED = "ON_CHANNEL_POST_UPDATED", /** * @eventProperty * This `RBEvent` event is sent when a post has been removed from the channel. * **Event Data** * - **channel**: The channel in which the post has been removed. * - **postId**: The removed post id. */ ON_CHANNEL_POST_REMOVED = "ON_CHANNEL_POST_REMOVED" } export declare enum ChannelSearchSortBy { /** * The list of channel found must be returned sorted by channel name. */ SORT_BY_CHANNEL_NAME = "name", /** * The list of channel found must be returned sorted by channel topic. */ SORT_BY_CHANNEL_TOPIC = "topic", /** * The list of channel found must be returned sorted by the number of channel members. */ SORT_BY_NB_CHANNEL_MEMBERS = "subscribers_count", /** * The list of channel found must be returned sorted by creation date. */ SORT_BY_CHANNEL_CREATION_DATE = "SORT_BY_CHANNEL_CREATION_DATE" } export declare enum ChannelSearchSortOrder { /** * The list of channel found are sorted in ascending order. */ SORT_ASCENDING = "1", /** * The list of channel found are sorted in decreasing order. */ SORT_DESCENDING = -1 } /** * The `ChannelCreationData` interface describes the options that can be sent to the createChannel() method * @example * ```ts * const newChannelData = { * "name": "MyCie internal news", * "category": "Innovation", * "topic": "A description of the channel's purpose", * "visibility" : ChannelVisibility.MY_COMPANY * "confidentiality" : ChannelConfidentiality.PRIVATE * "autoProvisionning": true * } * createChannel(newChannelData); * ``` */ export interface ChannelCreationData { /** * The channel name. * It must be unique. */ name: string; /** * The channel category */ category?: string; /** * The topic of the channel. */ topic?: string; /** * The visibility of the channel, i.e. who the channel is intended for. * Once the channel is created, the visibility cannot be changed. // * If this property is not specified, the visibility will be set to 'MY_COMPANY'. */ visibility: ChannelVisibility; /** * In addition to the channel visibility, this allows to refine the channel's audience. * Once the channel is created, the confidentiality cannot be changed. // * If this property is not specified, the visibility will be set to 'PUBLIC'. */ confidentiality: ChannelConfidentiality; /** * Automatically adds all users in my company as channel members. * The ability for a user to create a channel with this option enabled is subject to user right managed by the Company Administrator. * The role "all_company_channels_admin" must be assigned to the user who wants to create this type of channel. * Note that this option is authorized only if the channel visibility is set to 'company' and its confidentiality set to 'closed'. * Default value is FALSE. */ addAllCompanyUsers?: boolean; /** * Maximum number of posts to keep in the channel. * The maximum value is 100 and the default is 30. */ maxPost?: number; } export interface ChannelSearchOptions { /** * Search on channel name, in a case-insensitive way. * By default no search will be done on this field. */ name?: string; /** * Search on channel topic, in a case-insensitive * By default no search will be done on this field. */ topic?: string; /** * Search for channels belonging to one of the categories specified in the list. * The categories will be used in a case-sensitive way. * By default all defined category will be included. */ category?: string[]; /** * Search for channels that do not belong to any of the categories specified in the list. * The categories will be used in a case-sensitive way. * By default no category will be excluded. */ excludedCategory?: string[]; /** * Search for channels to which the connected user has subscribed or not. * By default all channels found will be returned regardless of the connected user's subscription status. */ subscribed?: boolean; /** * The number of results to return. * Limit value must be in range [1..100]. Default value is 50. * If the value is not in the authorized range, the request will be rejected and an error logged. */ limit?: number; /** * The position of the first found channel to retrieve * If no offset is specified, the returned results will start from the first channel found. * If the offset is greater than the total number of results, none are returned. */ offset?: number; /** * Sort the list of channels found according to a specified field. * By default, the channels are sorted by channel name. */ sortField?: ChannelSearchSortBy; /** * Sort order of the list of channels found. * By default, the results are sorted in ascending order. */ sortOrder?: ChannelSearchSortOrder; } /** * @internal * List of data provided as the result of the 'getUsers' API. */ export interface ChannelGetUsersResults { /** * The list of users (as User model) matching the search criteria. */ ChannelUsers: ChannelUser[]; /** * Total number of users who have subscribed to the channel. * Warning: The value returned by the server is not always correct! */ total: number; } /** * The `ChannelService` interface defines the Rainbow SDK ChannelService API */ export interface ChannelService { /** * Maximum number of posts that can be published in a channel. */ readonly maxChannelPosts: number; /** * The aggregated channel should be seen as a mix of posts from the channels the connected user follows, in chronological order. * It is available for the user as soon as the the user's company has subscribed to a dedicated offer including the channel feature. * This virtual is independent of all other channels created by users. * Messages are retrieved via the loadPosts(...) API */ aggregatedChannel: ChannelAggregated; /** * Subscribe to updates from the Channel service, all events are of RBEvent * @param callback - The callback function that will be called when events are received * @param eventNames - (optional) A list of event names that the user wants to receive when subscribing (used as filter) */ subscribe(callback: (event: RBEvent) => any, eventNames?: ChannelServiceEvents | ChannelServiceEvents[]): Subscription; /** * Indicates whether the Channel Service has been initialized or not. * This will be the case when all general information (except messages) on the channels to which * the user is subscribed is available. The same applies to the aggregated channel. * @returns True if the Channel Service has been initialized; False otherwise. */ isInitialized(): boolean; /** * Get all channels to which the user is subscribed. */ getChannels(): Promise; /** * Get a channel from its identifier. * @param channelId - The channel id */ getChannel(channelId: string): Promise; /** * Create a new channel. * The user who created a channel will be considered to be the owner of the channel. * The creation of a channel requires the user's company to subscribe to a dedicated offer including this feature. * Returns a Promise with the new created channel. * @param createChannelData - Channel settings that can be specified when it is created. */ createChannel(createChannelData: ChannelCreationData): Promise; /** * Search for channels matching some criteria who are visible to the user (only channel with a 'public' confidentiality). * At least one search criterion must be specified from options 'name', 'topic', 'category', 'excludedCategory' and 'subscribed'. * You can also specify several criteria, which will be combined during the search. * The way in which the list of channels found is returned can be customised: sorting according to one of the predefined fields and in the specified order. * @param options - Options for refining the channels to be provided. */ searchChannels(options?: ChannelSearchOptions): Promise; } /** * @internal */ export declare class ChannelServiceRB extends Service implements ChannelService { private logger; private authService; private xmppService; private profileService; private i18n; private contactService; private eventService; private errorHelperService; private portalURL; private isStarted; private channels; channelsList: Channel[]; readonly maxChannelPosts: number; aggregatedChannel: ChannelAggregated; private rxSubject; LIST_EVENT_TYPE: { ADD: number; UPDATE: number; REMOVE: number; DELETE: number; SUBSCRIBE: number; UNSUBSCRIBE: number; CREATE: number; }; xmppMessageHandler: StropheHandler; xmppManagementHandler: StropheHandler; notificationCounter: number; messageCounter: number; invitationCounter: number; CHANNEL_UPDATE_EVENT: string; CHANNEL_NOTIFICATION_NUMBER_UPDATED: string; CHANNEL_USER_SUBSCRIPTION_EVENT: string; static PAGE_SIZE: number; static getInstance(): ChannelServiceRB; static build(): ChannelServiceRB; protected constructor(); start(): Promise; stop(): Promise; reconnect(): Promise; isInitialized(): boolean; private attachXMPPListeners; private removeXMPPListeners; private channelErrorHandler; /** * Allows Channel service events to be sent. * Such events can be listened via channelService.subscribe() API * @param name - the name of the event * @param data - optionally, data associated with the event to be sent (as an object) */ sendEvent(name: ChannelServiceEvents, data?: any): void; /** * Subscribe to updates from the Channel service, all events are of RBEvent * @param callback - The callback function that will be called when events are received * @param eventNames - (optional) A list of event names that the user wants to receive when subscribing (used as filter) */ subscribe(callback: (event: RBEvent) => any, eventNames?: ChannelServiceEvents | ChannelServiceEvents[]): Subscription; private onChannelMessageReceived; private onChannelManagementReceived; /** * Handle the reception of a new message in the channel or the update of an existing one. * @param item - The id of the channel for which the post has been deleted */ private onMessagePublished; /** * Remove a post from the channel following an XMPP notification * @param channelId - The id of the channel for which the post has been deleted * @param messageId - The id of the message */ private onMessageRetracted; /** * Update an existing message following an XMPP notification * @param update - The information elements associated to the updated message */ private onMessageAppreciationUpdated; private onAddToChannel; private onUpdateToChannel; /** * User removed from the channel in the following scenarios * - The channel owner removes the user from the * whether it is still being invited or is already a member of the channel. * - The user declines an invitation. */ private onRemovedFromChannel; private onSubscribeToChannel; private onUnsubscribeToChannel; private onDeleteChannel; private onUserSubscribeEvent; private onUserUnsubscribeEvent; /** * Get from server all channels to which the user is subscribed or invited. * Retrieved channels are put in cache. * The channel service is considered initialised and therefore operational once this operation is complete. * The CHANNEL_SERVICE_STARTED event is sent as notification. */ private getMyChannels; private addChannelToCache; private removeChannelFromCache; /** * Get a channel from internal cache only. */ private getChannelFromCache; /** * Retrieves from server messages from the aggregated channel * @param maxMessages - Number of posts to retrive from this channel. * @param beforeDate - The posts must be prior to the specified timestamp (ISO 8601 format) * @param afterDate - The posts must occur after the specified timestamp (ISO 8601 format). */ private getAggregatedChannelPosts; /** * Get a specific message (Post) from a given channel * @param channelId - The id of the channel * @param messageId - The id of the message */ private getChannelMessage; /** * Get from cache a specific message (Post) from the aggregate Channel (global news feed). * @param messageId - The id of the message */ private getAggregateChannelMessage; /** * Get posts from a either a specific channel or the aggregated channel. * @param channel - The channel instance * @param beforeDate - The posts must be prior to the specified timestamp (ISO 8601 format) */ private getChannelMessages; /** * Retrieves the 10 most recent messages from the aggregated channel. * The channel has been reset, i.e. all existing messages have been deleted. */ private retrieveLatests; /** * Update of the Channel avatar * @param channelId - The id of the channel for which the avatar has been updated * @param avatar - The new channel avatar */ private onAvatarChange; private updateNotificationCounter; private decrementInvitationCounter; private chewReceivedItems; private updateChannelsList; /** * Update the channel general settings * Only the following settings are allowed to be modified: name, category, topic, max number of posts * @param channel - The channel to be updated. * @param channelSettings - The settings to be updated in the channel */ setSettings(channel: Channel, channelSettings: ChannelSettings): Promise; /** * Upload avatar to a channel and resize it to avatarSize * @param channel - The channel for which the custom avatar will be set * @param avatar - The image to be used as the channel's avatar * @param avatarSize - The size of the image (used as width and height) of the image */ uploadChannelAvatar(channel: ChannelRB, avatar: any, avatarSize: number): Promise; /** * Delete avatar of a channel * @param channel - The channel for which the custom avatar will be deleted */ deleteChannelAvatar(channel: ChannelRB): Promise; /** * Delete the specified channel. * Only the owner of the channel can delete it. * @param channel - The channel to be deleted. */ deleteChannel(channel: Channel): Promise; /** * Browse channels w/o category and subscription status; sorted on given field(s). * @param filter - Options for browsing channel. */ browseChannels(filter: any): Promise; /** * Search channel By Name * @param filter - Search filter limited to a pattern associated to the name */ findChannels(filter: any): Promise; /** * Retrieves from the server the specified number of posts for the specified channel. */ loadPosts(channel: ChannelRB, nbPosts: number): Promise; /** * Retrieves from server posts from a specific channel * @param maxPosts - Number of posts to retrive from this channel. * @param beforeDate - The posts must be prior to the specified timestamp (ISO 8601 format) * @param afterDate - The posts must occur after the specified timestamp (ISO 8601 format). */ getChannelPosts(channelId: string, maxPosts: number, beforeDate?: Date, afterDate?: Date): Promise; /** * Searches for posts in the channel based on their publication date * Please note that retrieved posts will not be considered as loaded, so NOT stored in the call posts cache. */ searchPosts(channel: ChannelRB, nbPosts: number, beforeDate?: Date, afterDate?: Date): Promise; /** * Publish a new post or modify an existing post in the channel * @param channelId - The channel id in which the post will be added * @param itemId - The message id. relevant only when modifying an existing post, empty for a new post publication. * @param type - The message format (Basic, HTML, Markdown). * @param message - The message text. * @param title - The message title. * @param images - Array of image Ids inserted in the post. * @param video - A video element included in the post. * @param attachments - Array of files Ids attached to the post. */ publishToChannel(channelId: string, itemId: string, type: string, message: string, title: string, images: any, video: any, attachments: any): Promise; /** * Removes a post from a channel. * @param channel - The channel in which the post will be removed. * @param post - The message to remove. */ deleteChannelPost(channel: ChannelRB, post: ChannelMessage): Promise; getChannelNextPage(channel: any, deferLoadNextPageIndex: number, reset?: boolean): Promise; ackMessage(messageId: string): void; /** * Get the users who are members of the channel and/or users invited to join it. * @param channel - The channel from which we're going to retrieve the list of users (members + invited). * @param options - Options for getting channel users. */ getChannelUsers(channel: Channel, options: ChannelGetUsersOptions): Promise; /** * Search for users matching the given name who are visible to the channel. * Members and/or non-members can be returned. * @param channel - The channel from which we're going to search users. * @param name - The search criterion based on the user's display name. * @param options - Options for refining the users to be provided. */ searchUsersByName(channel: Channel, name: string, options: ChannelSearchUsersOptions): Promise; /** * Update users in the channel. An update operation can be * - Adding one or more users to the channel to the channel * - Updating the role in the channel of one or more users. * - Removing one or more user members from the channel. * @param channel - The channel for which users will be modified. * @param channelUsers - The users to update. * @param channelUsers - The new role of the users to update. * A role with the value 'none' means that a user must be removed from the channel. */ updateUsers(channel: ChannelRB, channelUsers: ChannelUser[], role: ChannelUserRole): Promise; /** * Remove all users from A CHANNEL * @param channelId - The channel id */ removeAllUsersFromChannel(channelId: string): Promise; /** * Subscribe to a specified channel * @param channel - The channel that the user wants to subscribe. */ subscribeToChannel(channel: ChannelRB): Promise; /** * Unsubscribe to a specified channel * @param channel - The channel that the user wants to subscribe. */ unsubscribeToChannel(channel: ChannelRB): Promise; removeUnsubscribedChannelFromCache(channelId: string): void; /** * Accept an invitation to join the specified channel. * @param channel - The channel that the user accepts to join. */ acceptInvitation(channel: Channel): Promise; /** * Decline invitation to join the specified channel. * @param channel - The channel that the user declines to join. */ declineInvitation(channel: Channel): Promise; /** * For Notification Center */ getChannelInvitations(): Channel[]; muteChannel(channel: ChannelRB): Promise; unmuteChannel(channel: ChannelRB): Promise; /** * Update a user reaction to a post on a channel. * This includes adding, updating and removing a reaction. * @param channel - The channel in which the post was published. * @param post - The message for which the reaction is to be changed. * @param reaction - The user's new reaction. */ reactToPost(channel: Channel, post: ChannelMessage, reaction: ChannelPostReaction): Promise; getChannelMessageReactions(channelMessage: ChannelMessage, reaction: string): Promise; /** * Get all user reactions or a specific reaction to the current message on the channel. * @param post - The message for which the reaction is to be changed. * @param reaction - Optional filter by reaction type. If no filter is specified, all reactions will be returned. */ getPostUserReactions(post: ChannelMessage, reaction?: ChannelPostReaction): Promise; addComment(channel: ChannelRB, channelMessage: ChannelMessage, message: string): Promise; getComments(channel: ChannelRB, channelMessage: ChannelMessage): Promise; incrementMessagesCounter(): void; decrementMessagesCounter(): void; incrementInvitationCounter(): void; /** * Create a new channel. * The user who created a channel will be considered to be the owner of the channel. * The creation of a channel requires the user's company to subscribe to a dedicated offer including this feature. * Returns a Promise with the new created channel. * @param createChannelData - Channel settings that can be specified when it is created. */ createChannel(createChannelData: ChannelCreationData): Promise; /** * Get all channels to which the user is subscribed. */ getChannels(): Promise; /** * Get from server a channel from its identifier. * @param channelId - The channel id */ getChannel(channelId: string): Promise; /** * Search for channels matching some criteria who are visible to the user i.e. * - All Channels with a 'public' confidentiality. * - Channels with confidentiality 'private' or 'closed' only if the user is the owner. * The user can subscribe (if not already a member) or unsubscribe (if already a member) from the channels returned in the results, * UNLESS it is the owner. * Channels with confidentiality 'private' or 'closed' are not returned even if the user is a simple member of these channels. * Indeed, due to the specific nature of these confidential channels, users cannot subscribe to them themselves. * At least one search criterion must be specified from options 'name', 'topic', 'category', 'excludedCategory' and 'subscribed'. * You can also specify several criteria, which will be combined during the search. * The way in which the list of channels found is returned can be customised: sorting according to one of the predefined fields and in the specified order. * @param options - Options for refining the channels to be provided. */ searchChannels(options: ChannelSearchOptions): Promise; } //# sourceMappingURL=channel.service.d.ts.map