Skip to content

Commit

Permalink
fix(plugin-meetings): start transcription when guest user is admitted (
Browse files Browse the repository at this point in the history
…#3176)

Co-authored-by: Dipanshu Sharma <[email protected]>
  • Loading branch information
meta-dipanshu-sharma and Dipanshu Sharma authored Nov 14, 2023
1 parent 59fcce6 commit e30ff90
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 18 deletions.
35 changes: 23 additions & 12 deletions packages/@webex/plugin-meetings/src/meeting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ export default class Meeting extends StatelessWebexPlugin {
shareStatus: string;
statsAnalyzer: StatsAnalyzer;
transcription: Transcription;
receiveTranscription: boolean;
updateMediaConnections: (mediaConnections: any[]) => void;
endCallInitiateJoinReq: any;
endJoinReqResp: any;
Expand Down Expand Up @@ -1761,8 +1762,8 @@ export default class Meeting extends StatelessWebexPlugin {
LOCUSINFO.EVENTS.CONTROLS_MEETING_TRANSCRIBE_UPDATED,
({caption, transcribing}) => {
// @ts-ignore - config coming from registerPlugin
if (transcribing && this.transcription && this.config.receiveTranscription) {
this.receiveTranscription();
if (transcribing && !this.transcription && this.config.receiveTranscription) {
this.startTranscription();
} else if (!transcribing && this.transcription) {
Trigger.trigger(
this,
Expand Down Expand Up @@ -2261,8 +2262,17 @@ export default class Meeting extends StatelessWebexPlugin {
});
}
});
this.locusInfo.on(LOCUSINFO.EVENTS.SELF_ADMITTED_GUEST, (payload) => {
this.locusInfo.on(LOCUSINFO.EVENTS.SELF_ADMITTED_GUEST, async (payload) => {
this.stopKeepAlive();
// @ts-ignore
if (!this.transcription && (this.config.receiveTranscription || this.receiveTranscription)) {
if (this.isTranscriptionSupported()) {
await this.startTranscription();
LoggerProxy.logger.info(
'Meeting:index#setUpLocusInfoSelfListener --> enabled to receive transcription for guest user!'
);
}
}

if (payload) {
Trigger.trigger(
Expand Down Expand Up @@ -3725,9 +3735,9 @@ export default class Meeting extends StatelessWebexPlugin {
* @private
* @returns {Promise<void>} a promise to open the WebSocket connection
*/
private async receiveTranscription() {
private async startTranscription() {
LoggerProxy.logger.info(
`Meeting:index#receiveTranscription -->
`Meeting:index#startTranscription -->
Attempting to generate a web socket url.`
);

Expand All @@ -3744,7 +3754,7 @@ export default class Meeting extends StatelessWebexPlugin {
});

LoggerProxy.logger.info(
`Meeting:index#receiveTranscription -->
`Meeting:index#startTranscription -->
Generated web socket url succesfully.`
);

Expand All @@ -3756,7 +3766,7 @@ export default class Meeting extends StatelessWebexPlugin {
);

LoggerProxy.logger.info(
`Meeting:index#receiveTranscription -->
`Meeting:index#startTranscription -->
opened LLM web socket connection successfully.`
);

Expand All @@ -3777,7 +3787,7 @@ export default class Meeting extends StatelessWebexPlugin {
// @ts-ignore - fix type
this.transcription.connect(this.webex.credentials.supertoken.access_token);
} catch (error) {
LoggerProxy.logger.error(`Meeting:index#receiveTranscription --> ${error}`);
LoggerProxy.logger.error(`Meeting:index#startTranscription --> ${error}`);
Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.RECEIVE_TRANSCRIPTION_FAILURE, {
correlation_id: this.correlationId,
reason: error.message,
Expand Down Expand Up @@ -3950,6 +3960,7 @@ export default class Meeting extends StatelessWebexPlugin {
.then((join) => {
joinSuccess(join);
this.deferJoin = undefined;
this.receiveTranscription = !!options.receiveTranscription;
Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.JOIN_SUCCESS, {
correlation_id: this.correlationId,
});
Expand All @@ -3959,10 +3970,10 @@ export default class Meeting extends StatelessWebexPlugin {
.then(async (join) => {
if (isBrowser) {
// @ts-ignore - config coming from registerPlugin
if (this.config.receiveTranscription || options.receiveTranscription) {
if (this.config.receiveTranscription || this.receiveTranscription) {
if (this.isTranscriptionSupported()) {
await this.receiveTranscription();
LoggerProxy.logger.info('Meeting:index#join --> enabled to recieve transcription!');
await this.startTranscription();
LoggerProxy.logger.info('Meeting:index#join --> enabled to receive transcription!');
}
}
} else {
Expand Down Expand Up @@ -5698,7 +5709,7 @@ export default class Meeting extends StatelessWebexPlugin {
if (layoutType) {
if (!LAYOUT_TYPES.includes(layoutType)) {
return this.rejectWithErrorLog(
'Meeting:index#changeVideoLayout --> cannot change video layout, invalid layoutType recieved.'
'Meeting:index#changeVideoLayout --> cannot change video layout, invalid layoutType received.'
);
}

Expand Down
53 changes: 47 additions & 6 deletions packages/@webex/plugin-meetings/test/unit/spec/meeting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -770,12 +770,12 @@ describe('plugin-meetings', () => {
assert.equal(meeting.isTranscriptionSupported(), true);
});
});
describe('#receiveTranscription', () => {
describe('#startTranscription', () => {
it('should invoke subscribe method to invoke the callback', () => {
meeting.monitorTranscriptionSocketConnection = sinon.stub();
meeting.initializeTranscription = sinon.stub();

meeting.receiveTranscription().then(() => {
meeting.startTranscription().then(() => {
assert.equal(true, false);
assert.calledOnce(meeting.initializeTranscription);
assert.calledOnce(meeting.monitorTranscriptionSocketConnection);
Expand All @@ -786,7 +786,7 @@ describe('plugin-meetings', () => {
meeting.request = sinon.stub().returns(Promise.reject());

try {
await meeting.receiveTranscription();
await meeting.startTranscription();
} catch (err) {
assert(err, {});
}
Expand Down Expand Up @@ -840,12 +840,12 @@ describe('plugin-meetings', () => {
assert.calledOnce(MeetingUtil.joinMeeting);
assert.calledOnce(meeting.setLocus);
});
it('should invoke `receiveTranscription()` if receiveTranscription is set to true', async () => {
it('should invoke `startTranscription()` if receiveTranscription is set to true', async () => {
meeting.isTranscriptionSupported = sinon.stub().returns(true);
meeting.receiveTranscription = sinon.stub().returns(Promise.resolve());
meeting.startTranscription = sinon.stub().returns(Promise.resolve());

await meeting.join({receiveTranscription: true});
assert.calledOnce(meeting.receiveTranscription);
assert.calledOnce(meeting.startTranscription);
});

it('should not create new correlation ID on join immediately after create', async () => {
Expand Down Expand Up @@ -3578,8 +3578,49 @@ describe('plugin-meetings', () => {
);
done();
});
it('transcription should start when configured when guest admitted', (done) => {
meeting.isTranscriptionSupported = sinon.stub().returns(true);
meeting.receiveTranscription = sinon.stub().returns(true);
meeting.startTranscription = sinon.stub();

meeting.locusInfo.emit({function: 'test', file: 'test'}, 'SELF_ADMITTED_GUEST', test1);
assert.calledOnce(meeting.startTranscription);
done();
});
});

describe('#setupLocusControlsListener', () => {
it('transcription should start when meeting transcribe state is updated with active transcribing', (done) => {
const payload = {caption: true, transcribing: true};
meeting.startTranscription = sinon.stub();
meeting.config.receiveTranscription = true;
meeting.transcription = null;

meeting.locusInfo.emit({function: 'meeting/index', file: 'setupLocusControlsListener'}, 'CONTROLS_MEETING_TRANSCRIBE_UPDATED', payload);
assert.calledOnce(meeting.startTranscription);
done();
})

it('transcription should stop when meeting transcribe state is updated with inactive transcribing', (done) => {
const payload = {caption: false, transcribing: false};
meeting.startTranscription = sinon.stub();
meeting.config.receiveTranscription = true;
meeting.transcription = {};

meeting.locusInfo.emit({function: 'meeting/index', file: 'setupLocusControlsListener'}, 'CONTROLS_MEETING_TRANSCRIBE_UPDATED', payload);
assert.notCalled(meeting.startTranscription);
assert.calledTwice(TriggerProxy.trigger);
assert.calledWith(
TriggerProxy.trigger,
sinon.match.instanceOf(Meeting),
{file: 'meeting/index', function: 'setupLocusControlsListener'},
'meeting:receiveTranscription:stopped',
payload
);
done();
})
})

describe('#setUpLocusUrlListener', () => {
it('listens to the locus url update event', (done) => {
const newLocusUrl = 'newLocusUrl/12345';
Expand Down

0 comments on commit e30ff90

Please sign in to comment.