feat(iframe_api): Add invite functionality.
This commit is contained in:
committed by
Saúl Ibarra Corretgé
parent
d1af11c67e
commit
69eefc82a5
+18
-1
@@ -6,6 +6,7 @@ import {
|
||||
createApiEvent,
|
||||
sendAnalytics
|
||||
} from '../../react/features/analytics';
|
||||
import { sendInvitesForItems } from '../../react/features/invite';
|
||||
import { getJitsiMeetTransport } from '../transport';
|
||||
|
||||
import { API_ID } from './constants';
|
||||
@@ -107,8 +108,24 @@ function initCommands() {
|
||||
|
||||
return false;
|
||||
});
|
||||
transport.on('request', ({ name }, callback) => {
|
||||
transport.on('request', (request, callback) => {
|
||||
const { name } = request;
|
||||
|
||||
switch (name) {
|
||||
case 'invite':
|
||||
APP.store.dispatch(
|
||||
sendInvitesForItems(request.invitees))
|
||||
.then(failedInvites => {
|
||||
const failed = failedInvites.length === 0;
|
||||
|
||||
callback({
|
||||
result: failed ? undefined : true,
|
||||
error: failed
|
||||
? new Error('One or more invites failed!')
|
||||
: undefined
|
||||
});
|
||||
});
|
||||
break;
|
||||
case 'is-audio-muted':
|
||||
callback(APP.conference.isLocalAudioMuted());
|
||||
break;
|
||||
|
||||
Vendored
+21
-1
@@ -200,6 +200,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||
* authentication.
|
||||
* @param {string} [options.onload] - The onload function that will listen
|
||||
* for iframe onload event.
|
||||
* @param {Array<Object>} [options.invitees] - Array of objects containing
|
||||
* information about new participants that will be invited in the call.
|
||||
*/
|
||||
constructor(domain, ...args) {
|
||||
super();
|
||||
@@ -212,7 +214,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||
interfaceConfigOverwrite = {},
|
||||
noSSL = false,
|
||||
jwt = undefined,
|
||||
onload = undefined
|
||||
onload = undefined,
|
||||
invitees
|
||||
} = parseArguments(args);
|
||||
|
||||
this._parentNode = parentNode;
|
||||
@@ -232,6 +235,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||
}
|
||||
})
|
||||
});
|
||||
this._invitees = invitees;
|
||||
this._isLargeVideoVisible = true;
|
||||
this._numberOfParticipants = 0;
|
||||
this._participants = {};
|
||||
@@ -362,6 +366,9 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||
|
||||
switch (name) {
|
||||
case 'video-conference-joined':
|
||||
if (this._invitees) {
|
||||
this.invite(this._invitees);
|
||||
}
|
||||
this._myUserID = userID;
|
||||
this._participants[userID] = {
|
||||
avatarURL: data.avatarURL
|
||||
@@ -575,6 +582,19 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Invite people to the call.
|
||||
*
|
||||
* @param {Array<Object>} invitees - The invitees.
|
||||
* @returns {Promise} - Resolves on success and rejects on failure.
|
||||
*/
|
||||
invite(invitees) {
|
||||
return this._transport.sendRequest({
|
||||
name: 'invite',
|
||||
invitees
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the audio mute status.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user