/** * @module Channels */ import { Subject, Subscription } from "rxjs"; import { User } from '../models/user.model'; import { RBEvent } from '../models/event.model'; import { ChannelMessage, ChannelPost, ChannelPostPublication } from "./channelMessage.model"; /** * @internal * @eventProperty * Channel model internal events send to other service/component via sendInnerEvent() * Should not be used by SDK user */ export declare enum ChannelInnerEvents { /** * @eventProperty * This RB event is sent when the avatar of the channel may have been modified. */ ON_CHANNEL_AVATAR_UPDATED = "ON_CHANNEL_AVATAR_UPDATED" } /** * @eventProperty * Channel instance specific events. * Can listen to it via `Channel.subscribe()` API */ export declare enum ChannelEvents { /** * @eventProperty * This `RBEvent` event is sent when the main information of the channel have been updated. * This includes its settings (name, category, topic, number of posts) and avatar. */ ON_CHANNEL_INFORMATION_UPDATED = "ON_CHANNEL_INFORMATION_UPDATED", /** * @internal * @eventProperty * This `RBEvent` event is sent when channel notifications have been turned on (enabled) by the connected user. */ ON_CHANNEL_NOTIFICATIONS_ON = "ON_CHANNEL_NOTIFICATIONS_ON", /** * @internal * @eventProperty * This `RBEvent` event is sent when channel notifications have been turned off (disabled) by the connected user. */ ON_CHANNEL_NOTIFICATIONS_OFF = "ON_CHANNEL_NOTIFICATIONS_OFF", /** * @eventProperty * This `RBEvent` event is sent when the connected user has subscribed to a channel. */ ON_CHANNEL_SUBSCRIPTION = "ON_CHANNEL_SUBSCRIPTION", /** * @eventProperty * This `RBEvent` event is sent when the connected user has unsubscribed from a channel. */ ON_CHANNEL_UNSUBSCRIPTION = "ON_CHANNEL_UNSUBSCRIPTION", /** * @eventProperty * This `RBEvent` event is sent when additional posts have been loaded for the channel . */ ON_CHANNEL_POSTS_LOADED = "ON_CHANNEL_POSTS_LOADED", /** * @eventProperty * This `RBEvent` event is sent when a new post has been published in the channel. * **Event Data** * - **post**: The new published post. */ ON_POST_PUBLISHED = "ON_POST_PUBLISHED", /** * @eventProperty * This `RBEvent` event is sent when a post has been removed from the channel. * **Event Data** * - **postId**: The removed post id. */ ON_POST_REMOVED = "ON_POST_REMOVED", /** * @internal * @eventProperty * This `RBEvent` event is sent when all comments associated to a channel post haven been retrieved. * PMA OPEN POINT: Shouldn't this event be sent to the ChannelPost interface? */ ON_CHANNEL_COMMENTS_RETRIEVED = "ON_CHANNEL_COMMENTS_RETRIEVED", /** * @internal * @eventProperty * This `RBEvent` event is sent when a comment has been added to a post of the channel. * PMA OPEN POINT: Shouldn't this event be sent to the ChannelPost interface? */ ON_CHANNEL_COMMENT_ADDED = "ON_CHANNEL_COMMENT_ADDED" } /** * Channel visibility */ export declare enum ChannelVisibility { /** * Channel visibility limited to the users of my company only. * This type of channel is dedicated to your Company's internal communication. * Depending on the purpose, you can choose a confidentiality in order to limit the audience of the channel. */ MY_COMPANY = "company", /** * Channel visibility for all Rainbow users (users of my company and other companies). * This type of channel is dedicated to your Company's external communication. * The ability for a user to create a channel with this visibility is subject to user right managed by the Company Administrator. * The role "public_channels_admin" must be assigned to the user who wants to create this type of channel. */ ALL_USERS = "all" } /** * Channel confidentiality */ export declare enum ChannelConfidentiality { /** * Any member of your company and, according to the channel visibility, any Rainbow users can view and subscribe to the channel. * Users can also be invited directly by the channel owner at any time. * Users can unsubscribe at any time. */ PUBLIC = "public", /** * The channel can only be followed through an invitation sent by the owner of the channel. * Only invited people can consult the channel, they can unsubscribe at any time. */ PRIVATE = "private", /** * Only selected or all users belonging to the same company as the channel owner will be automatically subscribed to the channel. * They will not be able to unsubscribe. * Note that this option is authorized only if the channel visibility is set to 'company'. * The ability for a user to create a channel with this confidentiality is subject to user right managed by the Company Administrator. * The role "closed_channels_admin" must be assigned to the user who wants to create this type of channel. */ CLOSED = "closed" } /** * Channel mode as received from server. * Then split into 2 information items: Channel visibility and + Channel confidentiality * Exclusively used by UCaaS for the moment. * In addition, the SDK does not include everything to do with the notion of organisation. * @internal */ export declare enum ChannelMode { /** * Channel with 'company' visibility + 'public' confidentiality */ MY_COMPANY_PUBLIC = "company_public", /** * Channel with 'company' visibility + 'private' confidentiality */ MY_COMPANY_PRIVATE = "company_private", /** * Channel for a company having the visibility closed. * A Channel owned by such company must never be accessed outside publishthe company/organisation. */ MY_COMPANY_CLOSED = "company_closed", /** * Channel with 'all' visibility + 'public' confidentiality */ ALL_PUBLIC = "all_public", /** * Channel with 'all' visibility + 'private' confidentiality */ ALL_PRIVATE = "all_private", /** * Channel with 'organization' visibility + 'private' confidentiality */ ORGANIZATION_PRIVATE = "organization_private", /** * Channel with 'organization' visibility + 'private' confidentiality */ ORGANIZATION_PUBLIC = "organization_public" } /** * Channel user role * Each role gives access to different functionalities in Bubbles. */ export declare enum ChannelUserRole { /** * A user with the ‘none’ role is a user who is no longer a member of the channel following an unsubscription. * This role cannot be assigned directly to a user. * The use of this role is limited to the connected user and is set when it unsubscribe from the channel. * This is a temporary situation that makes it easier to re-subscribe to the same channel. */ NONE = "none", /** * A user with the ‘owner’ role is the user who created the channel. * This user is unique and the only one authorized to manage the channel: updating general information * (category, name, topic, avatar), inviting or removing users from the channel, authorising or * denying members permission to publish posts. * He also has the right to publish posts in the channel. * This role cannot be assigned directly to a user when adding a user to the channel or modifying a channel member role. */ OWNER = "owner", /** * A user with the 'member' role is a user who follows the channel. * The user is only permitted to view posts published in the channel; they are not allowed to publish any themselves. * This role can be assigned directly to a user when adding a user to the channel or modifying a channel member role. */ MEMBER = "member", /** * A user with the role of publisher is a user who is a member of the channel and also has the right to publish posts in it. * This role can be assigned directly to a user when adding a user to the channel or modifying a channel member role. */ PUBLISHER = "publisher" } /** * This interface defines specific user properties for a given channel. */ export interface ChannelUserInfos { /** * Indicates whether the user is currently being invited to join the channel. * If the data is not present, it means that there is no invitation in progress for this channel. * @readonly */ invited?: boolean; /** * Indicates whether the user has subscribed to the channel. * A user who is invited to join a channel has also the "subscribed" state set to 'false'. * @readonly */ subscribed?: boolean; /** * If the channel visibility is set to 'company' and the confidentiality to 'closed', * this indicates the date on which the user was automatically added to the channel. * Otherwise this corresponds to the date on which the user was invited to join the channel. ² * @readonly */ additionDate?: Date; /** * The user's role in the channel. * This corresponds to the type of channel affiliation that can be assigned to a new or an existing member. */ userRole: ChannelUserRole; } export interface ChannelUser extends User { /** * The user information related to a channel. * Its invitation status, its subscription status (and date) and its role in the channel. */ channelUser?: ChannelUserInfos; } /** * This interface defines the settings that can be sent to the setSettings channel API */ export interface ChannelSettings { /** * The channel name. * It must be unique. */ name?: string; /** * The channel category. */ category?: string; /** * The topic of the channel, i.e. a description explaining the purpose of the channel. */ topic?: string; /** * Maximum number of posts to keep in the channel. * The maximum value is 100 and the default is 30. * If this value is reduced when updating the settings for a channel, any surplus posts stored will be deleted. */ maxPost?: number; } export interface ChannelGetUsersOptions { /** * The position of the first found user to retrieve * If no offset is specified, the returned results will start from the first user found. * If the offset is greater than the total number of results, none are returned. */ offset?: number; /** * The number of results to return. * Limit value must be in range [1..100]. Default value is 20. * If the value is not in the authorized range, the request will be rejected and an error logged. */ limit?: number; /** * Filter the channel members to be searched according to their role (type of affiliation) within the channel. * If not specified, all members with the role 'owner', 'publisher' and 'member' will be searched. * Notes also that the role value 'none' is not managed and will be ignored. */ userRoles?: ChannelUserRole[]; /** * Filter on users invited to join the channel. * If not specified, no filter will be done on the invitation status. */ invited?: boolean; } export interface ChannelSearchUsersOptions { /** * The position of the first found user to retrieve * If no offset is specified, the returned results will start from the first user found. * If the offset is greater than the total number of results, none are returned. */ offset?: number; /** * The number of results to return. * Limit value must be in range [1..100]. Default value is 20. * If the value is not in the authorized range, the request will be rejected and an error logged. */ limit?: number; } export interface ChannelAggregated { /** * Fixed name given to the aggregated channel. * @readonly */ name: string; /** * Messages/Posts published in all channels to which the user is subscribed and which have already been retrieved. * @readonly */ messages: any[]; /** * Indicates whether a request to retrieve posts from the aggregate channel is in progress. * If so, another similar request will be ignored. * @readonly */ isLoading: boolean; /** * Indicates whether a request to load publications has already been made for the channel. * If this is the case, the publications already loaded can be retrieved via API getPosts(). * If not, API loadPosts(...) must be first used for this purpose to retrieve the N most recent publications. * @readonly */ loaded: boolean; /** * Indicates whether all posts from the aggregate channel have been retrieved. * @readonly */ complete: boolean; /** * Get all posts already loaded (via loadPosts(...) API) for the aggregated channel. * If no post load operation has already been performed, an error is reported rather than an empty array to make the distinction. */ getPosts(): ChannelPost[]; /** * Load the specified number of additional posts from the aggregated channel. Defaut value is 10. * @param nbPosts - number of channel posts to load. */ loadPosts(nbPosts?: number): Promise; } export interface Channel { /** * The channel unique identifier * @readonly */ id: string; /** * Channel creation date. Automatically set when the channel is created. * @readonly */ creationDate: Date; /** * The channel name. */ name: string; /** * The channel category. */ category: string; /** * The topic of the channel, i.e. a description explaining the purpose of the channel. */ topic: string; /** * The customized channel avatar. */ avatar?: string; /** * The channel avatar last modification date. * @readonly */ lastAvatarUpdateDate?: Date | null; /** * 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 'company'. * @readonly */ 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'. * @readonly */ confidentiality: ChannelConfidentiality; /** * The number of channel members. * By member, we mean users who have already subscribed to the channel, not those who have a pending invitation. * @readonly */ subscribersCount: number; /** * Information about the interaction between the connected user and this channel. */ channelConnectedUser: ChannelUserInfos; /** * Posts published in this channel that have already been retrieved. * @readonly */ messages: any[]; /** * Indicates whether a request to retrieve posts from the channel is in progress. * If so, another similar request will be ignored. * @readonly */ isLoading: boolean; /** * Indicates whether a request to load publications has already been made for the channel. * If this is the case, the publications already loaded can be retrieved via API getPosts(). * If not, API loadPosts(...) must be first used for this purpose to retrieve the N most recent publications. * @readonly */ loaded: boolean; /** * Indicates whether all posts from the channel have been retrieved. * @readonly */ complete: boolean; /** * Allows ChannelEvents events to be sent. * Such events can be listened via channel.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: ChannelEvents, data?: any): void; /** * Subscribe to channel updates, 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?: ChannelEvents[]): Subscription; /** * Follow the channel. */ follow(): Promise; /** * Unfollow the channel. * At any time, a user can decide to no longer follow a channel's news by unsubscribing from it. * This operation is only possible with a channel whose confidentiality is set to ‘public’ or ‘private’, not with a 'closed' channel. * Note that in this case, the channel will not be removed from the channels visible to the user * to make it easier for them to subscribe to it again if necessary (e.g. in the event of incorrect handling). * However, the connected user will no longer have any role in this channel (it will be reset to "none"). */ unfollow(): Promise; /** * Accept an invitation to join the channel. */ acceptInvitation(): Promise; /** * Decline invitation to join the channel. */ declineInvitation(): Promise; /** * Update the channel general settings * @param channelSettings - The settings to be updated in the channel */ setSettings(channelSettings: ChannelSettings): Promise; /** * Define a custom avatar for the channel. * This operation is only authorized for the owner of the channel. * @param base64AvatarImg - The image to be used as the channel's avatar * @param size - The size of the image (used as width and height) of the image (defaut value is 256). */ setCustomAvatar(base64AvatarImg: string, size?: number): Promise; /** * Remove the channel custom avatar * This operation is only authorized for the owner of the channel. */ removeCustomAvatar(): Promise; /** * Indicates whether the connected user is the owner of the channel. */ isConnectedUserOwner(): boolean; /** * Returns the User who created the channel. */ getOwner(): Promise; /** * Retrieve the number of posts published in the channel. */ getNumberOfPosts(): Promise; /** * Get users who are members of the channel and/or users invited to join it. * If no option is specified, this API returns the first users who are members of the channel, whatever their role. * @param options - Options for refining the channel users to be retrieved. */ getUsers(options?: ChannelGetUsersOptions): Promise; /** * Search for users matching the given name who are visible to the channel. * The scope of the possible users depends on the channel's configuration when it was created (settings 'visibility and 'confidentiality'). * The search is done using the first name and last name of the user and provides channel affiliation information if any exists. * If a found user has not subscribed to the channel, it will be possible to add them to it (by invitation or automatically). * If a found user has subscribed to the channel, you can modify their role or even remove them from the channel. * The list of users found is returned sorted by name, in ascending order. * @param name - The search criterion based on the user's display name. * @param options - Options for refining the users to be provided. */ searchUsers(name: string, options?: ChannelSearchUsersOptions): Promise; /** * Adds one or more users to the channel with the specified role, either simple member, or member with the right to publish. * Depending on the confidentiality of the channel defined when it was created, these users will either * be invited to join the channel or will be automatically subscribed to it. * @param users - The users to subscribe to the channel * @param role - The user's role. */ addUsers(users: ChannelUser[], role: ChannelUserRole): Promise; /** * Removes one or more user members from the channel. * @param users - The users to unsubscribe to the channel */ removeUsers(users: ChannelUser[]): Promise; /** * Update the role in the channel of a user who is a member of the channel or invited to join it. * @param user - The user whose role will be changed. * @param role - The user's new role. */ updateUserRole(user: ChannelUser, role: ChannelUserRole): Promise; /** * Delete the channel. * All channel members will be automatically unsubscribed. */ delete(): Promise; /** * Get all posts already loaded (via loadPosts(...) API) for the channel. * If no post load operation has already been performed, an error is reported rather than an empty array to make the distinction. */ getPosts(): ChannelPost[]; /** * Load the specified number of additional posts from the channel. Defaut value is 10. * @param nbPosts - number of channel posts to load. */ loadPosts(nbPosts?: number): Promise; /** * Searches for posts in the channel based on their publication date. * If before and after dates are specified, then posts published within that time interval will be searched for. * If only a 'before date' is specified, then posts prior to the specified timestamp will be searched for. * If only a 'after date' is specified, then posts after to the specified timestamp will be searched for. * Please note that retrieved posts will not be considered as loaded. * They may therefore not appear in the list of posts retrieved via the getPosts() API. * This feature should be considered as a snapshot of posts published between two dates. * @param nbPosts - Number of publications to return in results * @param beforeDate - The publication must be prior to the specified timestamp (ISO 8601 format) * @param afterDate - The publication must occur after the specified timestamp (ISO 8601 format). */ searchPosts(nbPosts: number, beforeDate: Date, afterDate: Date): Promise; /** * Publish a new post or modify an existing post in the channel * @param post - Information contained in the post to add or update in the channel. */ publish(post: ChannelPostPublication): Promise; /** * Method to return a simplified JSON representation of the Channel object */ toJSON(): any; } /** * @internal */ export declare class ChannelNewsFeed { messages: any[]; loaded: boolean; isLoading: boolean; complete: boolean; pageIndex: number; } /** * @internal */ export declare class ChannelAggregatedRB extends ChannelNewsFeed implements ChannelAggregated { name: string; private logger; private errorHelperService; private channelService?; private contactService?; private documentService?; /** * Get all posts already loaded (via loadPosts(...) API) for the aggregated channel. * If no post load operation has already been performed, an error is reported rather than an empty array to make the distinction. */ getPosts(): ChannelPost[]; /** * Load the specified number of additional posts from the aggregated channel. Defaut value is 10. * @param nbPosts - number of channel posts to load. */ loadPosts(nbPosts?: number): Promise; } /** * @internal */ export declare class ChannelRB extends ChannelNewsFeed implements Channel { id: string; creationDate: Date; /** The userd Id of the channel creator */ creatorId: string; name: string; category: string; topic: string; /** Visibility and confidentiality (audience) of the channel */ visibility: ChannelVisibility; confidentiality: ChannelConfidentiality; /** The customized channel avatar */ avatar: string; lastAvatarUpdateDate: Date | null; subscribersCount: number; channelConnectedUser: ChannelUserInfos; rxSubject: Subject>; innerRxSubject: Subject>; companyId: string; usersCount: number; /** * !! WARNING !! * The ‘visibility’ property received from the server appears to no longer be used. * It has been renamed to 'visibilityPubSub' and replaced in use by the ‘mode’ data. * However, its definition and use are retained in the .model file to avoid problems on very old channels * and thus maintain compatibility. * * "private" : a « Pub » channel, only the owner may publish posts.
* Managed by owner, the only one who can add or remove users in a private channels.
* Can't be found by search.
* "company" : « PubSub » channel (company users may join/leave) * May be found by search for users in the same company.
* "public" : « PubSub » public channel. * Only allowed users may create a "public" channel. * May be found by search for all users.
*/ private visibilityPubSub; /** The channel policy/behaviour based on 'visibility_confidentiality' */ mode: string; messagesCount: number; muted: boolean; private logger; private errorHelperService; private channelService?; private contactService?; private documentService?; protected constructor(); updateFromData(data: any): void; static createEmpty(): ChannelRB; static createFromData(data: any): ChannelRB; isNotMember(): ChannelUserRole; isMember(): boolean; isPublisher(): boolean; getAvatarSrc(): string; protected isChannelObjectEmpty(obj: any): boolean; sendEvent(name: ChannelEvents, data?: any): void; subscribe(callback: (event: RBEvent) => any, eventNames?: ChannelEvents | ChannelEvents[]): Subscription; sendInnerEvent(name: ChannelInnerEvents, data?: any): void; subscribeToInnerEvents(handler: (event: RBEvent) => any): Subscription; follow(): Promise; unfollow(): Promise; /** * Accept an invitation to join the channel. */ acceptInvitation(): Promise; /** * Decline invitation to join the channel. */ declineInvitation(): Promise; /** * Update the channel general settings. * This operation is only authorized for the owner of the channel. * @param channelSettings - The settings to be updated in the channel */ setSettings(channelSettings: ChannelSettings): Promise; setCustomAvatar(base64AvatarImg: string, size?: number): Promise; removeCustomAvatar(): Promise; get avatarSrc(): string; delete(): Promise; isConnectedUserOwner(): boolean; getOwner(): Promise; getNumberOfPosts(): Promise; getUsers(options?: ChannelGetUsersOptions): Promise; searchUsers(name: string, options?: ChannelSearchUsersOptions): Promise; addUsers(users: ChannelUser[], role: ChannelUserRole): Promise; removeUsers(users: ChannelUser[]): Promise; updateUserRole(user: ChannelUser, role: ChannelUserRole): Promise; getPosts(): ChannelPost[]; /** * Load the specified number of posts from the channel. Defaut value is 10. * @param nbPosts - number of channel posts to load. */ loadPosts(nbPosts?: number): Promise; searchPosts(nbPosts: number, beforeDate: Date, afterDate: Date): Promise; /** * Publish a new post or modify an existing post in the channel */ publish(post: ChannelPostPublication): Promise; toJSON(): any; } //# sourceMappingURL=channel.model.d.ts.map