Skip to content

Commit

Permalink
[NEW] Video Conference (#529)
Browse files Browse the repository at this point in the history
* Revert "Revert Video Conference commits"

This reverts commit 7415488.

* [NEW] [VideoConference] Allow apps to end calls and add users (#516)

* [NEW] [VideoConference] Allow apps to create new video conferences (#517)

* Publish package when merging to new/videoconf (#518)

* [NEW] Extra test for video conference builder

* New space on readme file

* [NEW] [Video Conference] Configure Provider Capabilities (#520)

Co-authored-by: Thassio Victor <[email protected]>
  • Loading branch information
pierre-lehnen-rc and thassiov authored Jun 27, 2022
1 parent 0fc04a2 commit a493a76
Show file tree
Hide file tree
Showing 61 changed files with 1,686 additions and 25 deletions.
5 changes: 4 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ jobs:
else
# Add build number to the end of the version
npm version --no-git-tag-version "$(node -p "require('./package.json').version").$CIRCLE_BUILD_NUM"
if [[ $CIRCLE_BRANCH == 'alpha' ]]; then
if [[ $CIRCLE_BRANCH == 'new/videoconf' ]]; then
npm run go-publish-videoconf
elif [[ $CIRCLE_BRANCH == 'alpha' ]]; then
npm run go-publish-alpha
else
npm run go-publish-beta
Expand Down Expand Up @@ -142,5 +144,6 @@ workflows:
only:
- alpha
- beta
- "new/videoconf"
tags:
only: /^v.*/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Thoughts While Working (for docs)
- Apps which don't provide a valid uuid4 id will be assigned one, but this is not recommended and your App should provide an id
- The language strings are only done on the clients (`TAPi18next.addResourceBundle(lang, projectName, translations);`)
- The implementer of this should restrict the server setting access and environmental variables. Idea is to allow the implementer to have a default set of restricted ones while letting the admin/owner of the server to restrict it even further or lift the restriction on some more. Simple interface with settings and checkbox to allow/disallow them. :thinking:
- The implementer of this should restrict the server setting access and environmental variables. Idea is to allow the implementer to have a default set of restricted ones while letting the admin/owner of the server to restrict it even further or lift the restriction on some more. Simple interface with settings and checkbox to allow/disallow them. :thinking:

## What does the Apps-Engine enable you to do?
The Apps-Engine is Rocket.Chat's _plugin framework_ - it provides the APIs for Rocket.Chat Apps to interact with the host system.
Expand Down
4 changes: 4 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ gulp.task('publish-beta', gulp.series(lint_ts, compile, bundle_sdk, shell.task([
gulp.task('publish-alpha', gulp.series(lint_ts, compile, bundle_sdk, shell.task([
'npm publish --access public --tag alpha'
])));

gulp.task('publish-videoconf', gulp.series(lint_ts, compile, bundle_sdk, shell.task([
'npm publish --access public --tag videoconf'
])));
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rocket.chat/apps-engine",
"version": "1.33.0-alpha",
"version": "1.33.0-videoconf",
"description": "The engine code for the Rocket.Chat Apps which manages, runs, translates, coordinates and all of that.",
"main": "index",
"typings": "index",
Expand All @@ -12,6 +12,7 @@
"bundle": "gulp bundle",
"compile": "gulp compile",
"go-publish": "gulp publish",
"go-publish-videoconf": "gulp publish-videoconf",
"go-publish-beta": "gulp publish-beta",
"go-publish-alpha": "gulp publish-alpha",
"unit-tests": "NODE_ENV=test ts-node ./tests/runner.ts",
Expand Down
4 changes: 4 additions & 0 deletions src/definition/accessors/IConfigurationExtend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ISchedulerExtend } from './ISchedulerExtend';
import { ISettingsExtend } from './ISettingsExtend';
import { ISlashCommandsExtend } from './ISlashCommandsExtend';
import { IUIExtend } from './IUIExtend';
import { IVideoConfProvidersExtend } from './IVideoConfProvidersExtend';

/**
* This accessor provides methods for declaring the configuration
Expand All @@ -29,4 +30,7 @@ export interface IConfigurationExtend {
readonly scheduler: ISchedulerExtend;
/** Accessor for registering different elements in the host UI */
readonly ui: IUIExtend;

/** Accessor for declaring the videoconf providers which your App provides. */
readonly videoConfProviders: IVideoConfProvidersExtend;
}
13 changes: 12 additions & 1 deletion src/definition/accessors/IModifyCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import { ILivechatMessage } from '../livechat';
import { IMessage } from '../messages';
import { IRoom } from '../rooms';
import { BlockBuilder } from '../uikit';
import { AppVideoConference } from '../videoConferences';
import { IDiscussionBuilder } from './IDiscussionBuilder';
import { ILivechatCreator } from './ILivechatCreator';
import { ILivechatMessageBuilder } from './ILivechatMessageBuilder';
import { IMessageBuilder } from './IMessageBuilder';
import { IRoomBuilder } from './IRoomBuilder';
import { IUploadCreator } from './IUploadCreator';
import { IVideoConferenceBuilder } from './IVideoConferenceBuilder';

export interface IModifyCreator {
/**
* Get the creator object responsible for the
Expand Down Expand Up @@ -60,11 +63,19 @@ export interface IModifyCreator {
*/
startDiscussion(data?: Partial<IRoom>): IDiscussionBuilder;

/**
* Starts the process for building a new video conference.
*
* @param data (optional) the initial data to pass into the builder,
* @return an IVideoConferenceBuilder instance
*/
startVideoConference(data?: Partial<AppVideoConference>): IVideoConferenceBuilder;

/**
* Finishes the creating process, saving the object to the database.
*
* @param builder the builder instance
* @return the resulting `id` of the resulting object
*/
finish(builder: IMessageBuilder | ILivechatMessageBuilder | IRoomBuilder | IDiscussionBuilder): Promise<string>;
finish(builder: IMessageBuilder | ILivechatMessageBuilder | IRoomBuilder | IDiscussionBuilder | IVideoConferenceBuilder): Promise<string>;
}
9 changes: 8 additions & 1 deletion src/definition/accessors/IModifyExtender.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IUser } from '../users';
import { IMessageExtender } from './IMessageExtender';
import { IRoomExtender } from './IRoomExtender';
import { IVideoConferenceExtender } from './IVideoConferenceExtend';

export interface IModifyExtender {
/**
Expand All @@ -23,11 +24,17 @@ export interface IModifyExtender {
*/
extendRoom(roomId: string, updater: IUser): Promise<IRoomExtender>;

/**
* Modifies a video conference in a non-destructive way: Properties can be added to it,
* but existing properties cannot be changed.
*/
extendVideoConference(id: string): Promise<IVideoConferenceExtender>;

/**
* Finishes the extending process, saving the object to the database.
* Note: If there is an issue or error while updating, this will throw an error.
*
* @param extender the extender instance
*/
finish(extender: IRoomExtender | IMessageExtender): Promise<void>;
finish(extender: IRoomExtender | IMessageExtender | IVideoConferenceExtender): Promise<void>;
}
3 changes: 3 additions & 0 deletions src/definition/accessors/IRead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { IPersistenceRead } from './IPersistenceRead';
import { IRoomRead } from './IRoomRead';
import { IUploadRead } from './IUploadRead';
import { IUserRead } from './IUserRead';
import type { IVideoConferenceRead } from './IVideoConferenceRead';

/**
* The IRead accessor provides methods for accessing the
Expand Down Expand Up @@ -35,4 +36,6 @@ export interface IRead {
getLivechatReader(): ILivechatRead;
getUploadReader(): IUploadRead;
getCloudWorkspaceReader(): ICloudWorkspaceRead;

getVideoConferenceReader(): IVideoConferenceRead;
}
15 changes: 15 additions & 0 deletions src/definition/accessors/IVideoConfProvidersExtend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { IVideoConfProvider } from '../videoConfProviders';

/**
* This accessor provides methods for adding videoconf providers.
* It is provided during the initialization of your App
*/

export interface IVideoConfProvidersExtend {
/**
* Adds a videoconf provider
*
* @param provider the provider information
*/
provideVideoConfProvider(provider: IVideoConfProvider): Promise<void>;
}
30 changes: 30 additions & 0 deletions src/definition/accessors/IVideoConferenceBuilder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { RocketChatAssociationModel } from '../metadata';
import { AppVideoConference } from '../videoConferences';

export interface IVideoConferenceBuilder {
kind: RocketChatAssociationModel.VIDEO_CONFERENCE;

setData(call: Partial<AppVideoConference>): IVideoConferenceBuilder;

setRoomId(rid: string): IVideoConferenceBuilder;

getRoomId(): string;

setCreatedBy(userId: string): IVideoConferenceBuilder;

getCreatedBy(): string;

setProviderName(name: string): IVideoConferenceBuilder;

getProviderName(): string;

setProviderData(data: Record<string, any>): IVideoConferenceBuilder;

getProviderData(): Record<string, any>;

setTitle(name: string): IVideoConferenceBuilder;

getTitle(): string;

getVideoConference(): AppVideoConference;
}
19 changes: 19 additions & 0 deletions src/definition/accessors/IVideoConferenceExtend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { RocketChatAssociationModel } from '../metadata';
import { IVideoConferenceUser, VideoConference } from '../videoConferences';
import { VideoConferenceMember } from '../videoConferences/IVideoConference';

export interface IVideoConferenceExtender {
kind: RocketChatAssociationModel.VIDEO_CONFERENCE;

setProviderData(value: Record<string, any>): IVideoConferenceExtender;

setStatus(value: VideoConference['status']): IVideoConferenceExtender;

setEndedBy(value: IVideoConferenceUser['_id']): IVideoConferenceExtender;

setEndedAt(value: VideoConference['endedAt']): IVideoConferenceExtender;

addUser(userId: VideoConferenceMember['_id'], ts?: VideoConferenceMember['ts']): IVideoConferenceExtender;

getVideoConference(): VideoConference;
}
15 changes: 15 additions & 0 deletions src/definition/accessors/IVideoConferenceRead.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { VideoConference } from '../videoConferences/IVideoConference';

/**
* This accessor provides methods for accessing
* video conferences in a read-only-fashion.
*/
export interface IVideoConferenceRead {
/**
* Gets a video conference by an id.
*
* @param id the id of the video conference
* @returns the video conference
*/
getById(id: string): Promise<VideoConference | undefined>;
}
4 changes: 4 additions & 0 deletions src/definition/accessors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ export * from './IUploadCreator';
export * from './IUploadRead';
export * from './IUserBuilder';
export * from './IUserRead';
export * from './IVideoConferenceBuilder';
export * from './IVideoConferenceExtend';
export * from './IVideoConferenceRead';
export * from './IVideoConfProvidersExtend';
3 changes: 3 additions & 0 deletions src/definition/metadata/AppMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export enum AppMethod {
_COMMAND_PREVIEWER = 'previewer',
_COMMAND_PREVIEW_EXECUTOR = 'executePreviewItem',
_JOB_PROCESSOR = 'jobProcessor',
_VIDEOCONF_GENERATE_URL = 'generateUrl',
_VIDEOCONF_CUSTOMIZE_URL = 'customizeUrl',
_VIDEOCONF_IS_CONFIGURED = 'isFullyConfigured',
INITIALIZE = 'initialize',
ONENABLE = 'onEnable',
ONDISABLE = 'onDisable',
Expand Down
1 change: 1 addition & 0 deletions src/definition/metadata/RocketChatAssociations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum RocketChatAssociationModel {
USER = 'user',
FILE = 'file',
MISC = 'misc',
VIDEO_CONFERENCE = 'video-conference',
}

export class RocketChatAssociationRecord {
Expand Down
31 changes: 31 additions & 0 deletions src/definition/videoConfProviders/IVideoConfProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { IVideoConferenceUser } from '../videoConferences/IVideoConferenceUser';
import { IVideoConferenceOptions } from './IVideoConferenceOptions';
import { VideoConfData, VideoConfDataExtended } from './VideoConfData';

/**
* Represents a video conference provider
*/
export interface IVideoConfProvider {
name: string;

capabilities?: {
// Indicates if Rocket.Chat can determine if the user's microphone will start muted or not
mic?: boolean;
// Indicates if Rocket.Chat can determine if the user's camera will start turned on or not
cam?: boolean;
// Indicates if Rocket.Chat can send a custom title for the video conferences
title?: boolean;
};

// Optional function that can be used to determine if the provider is ready to use or still needs to be configured
isFullyConfigured?(): Promise<boolean>;

/**
* The function which gets called when a new video conference url is requested
*/
generateUrl(call: VideoConfData): Promise<string>;
/**
* The function which gets called whenever a user join url is requested
*/
customizeUrl(call: VideoConfDataExtended, user?: IVideoConferenceUser, options?: IVideoConferenceOptions): Promise<string>;
}
4 changes: 4 additions & 0 deletions src/definition/videoConfProviders/IVideoConferenceOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface IVideoConferenceOptions {
mic?: boolean;
cam?: boolean;
}
5 changes: 5 additions & 0 deletions src/definition/videoConfProviders/VideoConfData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { IGroupVideoConference, IVideoConference } from '../videoConferences/IVideoConference';

export type VideoConfData = Pick<IVideoConference, '_id' | 'type' | 'rid' | 'createdBy' | 'providerData'> & { title?: IGroupVideoConference['title'] };

export type VideoConfDataExtended = VideoConfData & Required<Pick<IVideoConference, 'url'>>;
10 changes: 10 additions & 0 deletions src/definition/videoConfProviders/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { IVideoConferenceOptions } from './IVideoConferenceOptions';
import { IVideoConfProvider } from './IVideoConfProvider';
import { VideoConfData, VideoConfDataExtended } from './VideoConfData';

export {
IVideoConferenceOptions,
IVideoConfProvider,
VideoConfData,
VideoConfDataExtended,
};
4 changes: 4 additions & 0 deletions src/definition/videoConferences/AppVideoConference.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import type { IGroupVideoConference } from './IVideoConference';

// Type for video conferences being created by an app
export type AppVideoConference = Pick<IGroupVideoConference, 'rid' | 'providerName' | 'providerData' | 'title'> & { createdBy: IGroupVideoConference['createdBy']['_id'] };
50 changes: 50 additions & 0 deletions src/definition/videoConferences/IVideoConference.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { IVideoConferenceUser } from './IVideoConferenceUser';

export type VideoConferenceMember = IVideoConferenceUser & {
ts: Date;
};

export enum VideoConferenceStatus {
CALLING = 0,
STARTED = 1,
ENDED = 2,
}

export interface IVideoConference {
_id: string;
_updatedAt: Date;
type: 'direct' | 'videoconference' | 'livechat';
rid: string;
users: Array<VideoConferenceMember>;
status: VideoConferenceStatus;
messages: {
started?: string;
ended?: string;
};
url?: string;

createdBy: IVideoConferenceUser;
createdAt: Date;

endedBy?: IVideoConferenceUser;
endedAt?: Date;

providerName: string;
providerData?: Record<string, any>;
}

export interface IDirectVideoConference extends IVideoConference {
type: 'direct';
}

export interface IGroupVideoConference extends IVideoConference {
type: 'videoconference';
anonymousUsers: number;
title: string;
}

export interface ILivechatVideoConference extends IVideoConference {
type: 'livechat';
}

export type VideoConference = IDirectVideoConference | IGroupVideoConference | ILivechatVideoConference;
5 changes: 5 additions & 0 deletions src/definition/videoConferences/IVideoConferenceUser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface IVideoConferenceUser {
_id: string;
username: string;
name: string;
}
12 changes: 12 additions & 0 deletions src/definition/videoConferences/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { AppVideoConference } from './AppVideoConference';
import { IDirectVideoConference, IGroupVideoConference, IVideoConference, VideoConference } from './IVideoConference';
import { IVideoConferenceUser } from './IVideoConferenceUser';

export {
AppVideoConference,
IDirectVideoConference,
IGroupVideoConference,
IVideoConference,
IVideoConferenceUser,
VideoConference,
};
Loading

0 comments on commit a493a76

Please sign in to comment.