@webex/plugin-meetings 3.0.0-beta.296 → 3.0.0-beta.297
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/breakouts/breakout.js +1 -1
- package/dist/breakouts/index.js +1 -1
- package/dist/common/errors/reclaim-host-role-errors.js +158 -0
- package/dist/common/errors/reclaim-host-role-errors.js.map +1 -0
- package/dist/constants.js +29 -2
- package/dist/constants.js.map +1 -1
- package/dist/interpretation/index.js +1 -1
- package/dist/interpretation/siLanguage.js +1 -1
- package/dist/members/index.js +17 -1
- package/dist/members/index.js.map +1 -1
- package/dist/types/common/errors/reclaim-host-role-errors.d.ts +60 -0
- package/dist/types/constants.d.ts +26 -0
- package/dist/webinar/index.js +1 -1
- package/package.json +19 -19
- package/src/common/errors/reclaim-host-role-errors.ts +134 -0
- package/src/constants.ts +31 -0
- package/src/members/index.ts +29 -2
- package/test/unit/spec/members/index.js +131 -18
package/src/members/index.ts
CHANGED
|
@@ -5,11 +5,24 @@ import {isEmpty} from 'lodash';
|
|
|
5
5
|
// @ts-ignore
|
|
6
6
|
import {StatelessWebexPlugin} from '@webex/webex-core';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
MEETINGS,
|
|
10
|
+
EVENT_TRIGGERS,
|
|
11
|
+
FLOOR_ACTION,
|
|
12
|
+
CONTENT,
|
|
13
|
+
WHITEBOARD,
|
|
14
|
+
ASSIGN_ROLES_ERROR_CODES,
|
|
15
|
+
} from '../constants';
|
|
9
16
|
import Trigger from '../common/events/trigger-proxy';
|
|
10
17
|
import Member from '../member';
|
|
11
18
|
import LoggerProxy from '../common/logs/logger-proxy';
|
|
12
19
|
import ParameterError from '../common/errors/parameter';
|
|
20
|
+
import {
|
|
21
|
+
ReclaimHostEmptyWrongKeyError,
|
|
22
|
+
ReclaimHostIsHostAlreadyError,
|
|
23
|
+
ReclaimHostNotAllowedError,
|
|
24
|
+
ReclaimHostNotSupportedError,
|
|
25
|
+
} from '../common/errors/reclaim-host-role-errors';
|
|
13
26
|
|
|
14
27
|
import MembersCollection from './collection';
|
|
15
28
|
import MembersRequest from './request';
|
|
@@ -856,7 +869,21 @@ export default class Members extends StatelessWebexPlugin {
|
|
|
856
869
|
}
|
|
857
870
|
const options = MembersUtil.generateRoleAssignmentMemberOptions(memberId, roles, this.locusUrl);
|
|
858
871
|
|
|
859
|
-
return this.membersRequest.assignRolesMember(options)
|
|
872
|
+
return this.membersRequest.assignRolesMember(options).catch((error: any) => {
|
|
873
|
+
const errorCode = error.body?.errorCode;
|
|
874
|
+
switch (errorCode) {
|
|
875
|
+
case ASSIGN_ROLES_ERROR_CODES.ReclaimHostNotSupportedErrorCode:
|
|
876
|
+
return Promise.reject(new ReclaimHostNotSupportedError());
|
|
877
|
+
case ASSIGN_ROLES_ERROR_CODES.ReclaimHostNotAllowedErrorCode:
|
|
878
|
+
return Promise.reject(new ReclaimHostNotAllowedError());
|
|
879
|
+
case ASSIGN_ROLES_ERROR_CODES.ReclaimHostEmptyWrongKeyErrorCode:
|
|
880
|
+
return Promise.reject(new ReclaimHostEmptyWrongKeyError());
|
|
881
|
+
case ASSIGN_ROLES_ERROR_CODES.ReclaimHostIsHostAlreadyErrorCode:
|
|
882
|
+
return Promise.reject(new ReclaimHostIsHostAlreadyError());
|
|
883
|
+
default:
|
|
884
|
+
return Promise.reject(error);
|
|
885
|
+
}
|
|
886
|
+
});
|
|
860
887
|
}
|
|
861
888
|
|
|
862
889
|
/**
|
|
@@ -17,6 +17,12 @@ import MembersUtil from '@webex/plugin-meetings/src/members/util';
|
|
|
17
17
|
import * as MembersRequestImport from '@webex/plugin-meetings/src/members/request';
|
|
18
18
|
import Trigger from '@webex/plugin-meetings/src/common/events/trigger-proxy';
|
|
19
19
|
import {EVENT_TRIGGERS} from '@webex/plugin-meetings/src/constants';
|
|
20
|
+
import {
|
|
21
|
+
ReclaimHostEmptyWrongKeyError,
|
|
22
|
+
ReclaimHostIsHostAlreadyError,
|
|
23
|
+
ReclaimHostNotAllowedError,
|
|
24
|
+
ReclaimHostNotSupportedError,
|
|
25
|
+
} from '../../../../src/common/errors/reclaim-host-role-errors';
|
|
20
26
|
|
|
21
27
|
const {assert} = chai;
|
|
22
28
|
|
|
@@ -336,8 +342,18 @@ describe('plugin-meetings', () => {
|
|
|
336
342
|
});
|
|
337
343
|
});
|
|
338
344
|
|
|
339
|
-
describe('#assignRoles', () => {
|
|
340
|
-
const
|
|
345
|
+
describe.only('#assignRoles', () => {
|
|
346
|
+
const fakeRoles = [
|
|
347
|
+
{type: 'PRESENTER', hasRole: true},
|
|
348
|
+
{type: 'MODERATOR', hasRole: false},
|
|
349
|
+
{type: 'COHOST', hasRole: true},
|
|
350
|
+
];
|
|
351
|
+
|
|
352
|
+
const resolvedValue = "it worked";
|
|
353
|
+
|
|
354
|
+
const genericMessage = 'Generic error from the API';
|
|
355
|
+
|
|
356
|
+
const setup = (locusUrl, errorCode) => {
|
|
341
357
|
const members = createMembers({url: locusUrl});
|
|
342
358
|
|
|
343
359
|
const spies = {
|
|
@@ -345,9 +361,14 @@ describe('plugin-meetings', () => {
|
|
|
345
361
|
MembersUtil,
|
|
346
362
|
'generateRoleAssignmentMemberOptions'
|
|
347
363
|
),
|
|
348
|
-
assignRolesMember: sandbox.spy(members.membersRequest, 'assignRolesMember'),
|
|
349
364
|
};
|
|
350
365
|
|
|
366
|
+
if (errorCode) {
|
|
367
|
+
spies.assignRolesMember = sandbox.stub(members.membersRequest, 'assignRolesMember').rejects({body: {errorCode}, message: genericMessage});
|
|
368
|
+
} else {
|
|
369
|
+
spies.assignRolesMember = sandbox.stub(members.membersRequest, 'assignRolesMember').resolves(resolvedValue);
|
|
370
|
+
}
|
|
371
|
+
|
|
351
372
|
return {members, spies};
|
|
352
373
|
};
|
|
353
374
|
|
|
@@ -357,6 +378,21 @@ describe('plugin-meetings', () => {
|
|
|
357
378
|
assert.notCalled(spies.assignRolesMember);
|
|
358
379
|
};
|
|
359
380
|
|
|
381
|
+
const checkError = async (error, expectedMemberId, expectedRoles, expectedLocusUrl, resultPromise, expectedMessage, spies) => {
|
|
382
|
+
await assert.isRejected(resultPromise, error, expectedMessage);
|
|
383
|
+
assert.calledOnceWithExactly(
|
|
384
|
+
spies.generateRoleAssignmentMemberOptions,
|
|
385
|
+
expectedMemberId,
|
|
386
|
+
expectedRoles,
|
|
387
|
+
expectedLocusUrl
|
|
388
|
+
);
|
|
389
|
+
assert.calledOnceWithExactly(spies.assignRolesMember, {
|
|
390
|
+
memberId: expectedMemberId,
|
|
391
|
+
roles: expectedRoles,
|
|
392
|
+
locusUrl: expectedLocusUrl,
|
|
393
|
+
});
|
|
394
|
+
};
|
|
395
|
+
|
|
360
396
|
const checkValid = async (
|
|
361
397
|
resultPromise,
|
|
362
398
|
spies,
|
|
@@ -364,7 +400,7 @@ describe('plugin-meetings', () => {
|
|
|
364
400
|
expectedRoles,
|
|
365
401
|
expectedLocusUrl
|
|
366
402
|
) => {
|
|
367
|
-
await assert.isFulfilled(resultPromise);
|
|
403
|
+
const resolvedValue = await assert.isFulfilled(resultPromise);
|
|
368
404
|
assert.calledOnceWithExactly(
|
|
369
405
|
spies.generateRoleAssignmentMemberOptions,
|
|
370
406
|
expectedMemberId,
|
|
@@ -376,7 +412,7 @@ describe('plugin-meetings', () => {
|
|
|
376
412
|
roles: expectedRoles,
|
|
377
413
|
locusUrl: expectedLocusUrl,
|
|
378
414
|
});
|
|
379
|
-
assert.strictEqual(
|
|
415
|
+
assert.strictEqual(resolvedValue, resolvedValue);
|
|
380
416
|
};
|
|
381
417
|
|
|
382
418
|
it('should not make a request if there is no member id', async () => {
|
|
@@ -387,7 +423,7 @@ describe('plugin-meetings', () => {
|
|
|
387
423
|
await checkInvalid(
|
|
388
424
|
resultPromise,
|
|
389
425
|
'The member id must be defined to assign the roles to a member.',
|
|
390
|
-
spies
|
|
426
|
+
spies,
|
|
391
427
|
);
|
|
392
428
|
});
|
|
393
429
|
|
|
@@ -399,7 +435,92 @@ describe('plugin-meetings', () => {
|
|
|
399
435
|
await checkInvalid(
|
|
400
436
|
resultPromise,
|
|
401
437
|
'The associated locus url for this meetings members object must be defined.',
|
|
402
|
-
spies
|
|
438
|
+
spies,
|
|
439
|
+
);
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
it('should not make a request if locus throws ReclaimHostNotSupportedError', async () => {
|
|
443
|
+
const memberId = uuid.v4();
|
|
444
|
+
const {members, spies} = setup(url1, 2400127);
|
|
445
|
+
|
|
446
|
+
const resultPromise = members.assignRoles(memberId, fakeRoles);
|
|
447
|
+
|
|
448
|
+
await checkError(
|
|
449
|
+
ReclaimHostNotSupportedError,
|
|
450
|
+
memberId,
|
|
451
|
+
fakeRoles,
|
|
452
|
+
url1,
|
|
453
|
+
resultPromise,
|
|
454
|
+
'Non converged meetings, PSTN or SIP users in converged meetings are not supported currently.',
|
|
455
|
+
spies,
|
|
456
|
+
);
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
it('should not make a request if locus throws ReclaimHostNotAllowedError', async () => {
|
|
460
|
+
const memberId = uuid.v4();
|
|
461
|
+
const {members, spies} = setup(url1, 2403135);
|
|
462
|
+
|
|
463
|
+
const resultPromise = members.assignRoles(memberId, fakeRoles);
|
|
464
|
+
|
|
465
|
+
await checkError(
|
|
466
|
+
ReclaimHostNotAllowedError,
|
|
467
|
+
memberId,
|
|
468
|
+
fakeRoles,
|
|
469
|
+
url1,
|
|
470
|
+
resultPromise,
|
|
471
|
+
'Reclaim Host Role Not Allowed For Other Participants. Participants cannot claim host role in PMR meeting, space instant meeting or escalated instant meeting. However, the original host still can reclaim host role when it manually makes another participant to be the host.',
|
|
472
|
+
spies,
|
|
473
|
+
);
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
it('should not make a request if locus throws ReclaimHostEmptyWrongKeyError', async () => {
|
|
477
|
+
const memberId = uuid.v4();
|
|
478
|
+
const {members, spies} = setup(url1, 2403136);
|
|
479
|
+
|
|
480
|
+
const resultPromise = members.assignRoles(memberId, fakeRoles);
|
|
481
|
+
|
|
482
|
+
await checkError(
|
|
483
|
+
ReclaimHostEmptyWrongKeyError,
|
|
484
|
+
memberId,
|
|
485
|
+
fakeRoles,
|
|
486
|
+
url1,
|
|
487
|
+
resultPromise,
|
|
488
|
+
'Host Key Not Specified Or Matched. The original host can reclaim the host role without entering the host key. However, any other person who claims the host role must enter the host key to get it.',
|
|
489
|
+
spies,
|
|
490
|
+
);
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
it('should not make a request if locus throws ReclaimHostIsHostAlreadyError', async () => {
|
|
494
|
+
const memberId = uuid.v4();
|
|
495
|
+
const {members, spies} = setup(url1, 2409150);
|
|
496
|
+
|
|
497
|
+
const resultPromise = members.assignRoles(memberId, fakeRoles);
|
|
498
|
+
|
|
499
|
+
await checkError(
|
|
500
|
+
ReclaimHostIsHostAlreadyError,
|
|
501
|
+
memberId,
|
|
502
|
+
fakeRoles,
|
|
503
|
+
url1,
|
|
504
|
+
resultPromise,
|
|
505
|
+
'Participant Having Host Role Already. Participant who sends request to reclaim host role has already a host role.',
|
|
506
|
+
spies,
|
|
507
|
+
);
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
it('should not make a request if locus throws a different error', async () => {
|
|
511
|
+
const memberId = uuid.v4();
|
|
512
|
+
const {members, spies} = setup(url1, 1234);
|
|
513
|
+
|
|
514
|
+
const resultPromise = members.assignRoles(memberId, fakeRoles);
|
|
515
|
+
|
|
516
|
+
await checkError(
|
|
517
|
+
{body: {errorCode: 1234}, message: genericMessage},
|
|
518
|
+
memberId,
|
|
519
|
+
fakeRoles,
|
|
520
|
+
url1,
|
|
521
|
+
resultPromise,
|
|
522
|
+
genericMessage,
|
|
523
|
+
spies,
|
|
403
524
|
);
|
|
404
525
|
});
|
|
405
526
|
|
|
@@ -407,22 +528,14 @@ describe('plugin-meetings', () => {
|
|
|
407
528
|
const memberId = uuid.v4();
|
|
408
529
|
const {members, spies} = setup(url1);
|
|
409
530
|
|
|
410
|
-
const resultPromise = members.assignRoles(memberId,
|
|
411
|
-
{type: 'PRESENTER', hasRole: true},
|
|
412
|
-
{type: 'MODERATOR', hasRole: false},
|
|
413
|
-
{type: 'COHOST', hasRole: true},
|
|
414
|
-
]);
|
|
531
|
+
const resultPromise = members.assignRoles(memberId, fakeRoles);
|
|
415
532
|
|
|
416
533
|
await checkValid(
|
|
417
534
|
resultPromise,
|
|
418
535
|
spies,
|
|
419
536
|
memberId,
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
{type: 'MODERATOR', hasRole: false},
|
|
423
|
-
{type: 'COHOST', hasRole: true},
|
|
424
|
-
],
|
|
425
|
-
url1
|
|
537
|
+
fakeRoles,
|
|
538
|
+
url1,
|
|
426
539
|
);
|
|
427
540
|
});
|
|
428
541
|
});
|