[FIX] Jitsi integration sending random "join now" messages (#22277)

* [FIX] Jitsi integration sending random "join now" messages
pull/20650/head^2
pierre-lehnen-rc 5 years ago committed by GitHub
parent 3681868b0a
commit aecc4d3656
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/api/server/v1/video-conference.js
  2. 4
      app/videobridge/server/methods/jitsiSetTimeout.js
  3. 17
      client/views/room/contextualBar/Call/Jitsi/CallJitsWithData.js
  4. 8
      client/views/room/contextualBar/Call/Jitsi/lib/JitsiBridge.js

@ -5,7 +5,7 @@ import { API } from '../api';
API.v1.addRoute('video-conference/jitsi.update-timeout', { authRequired: true }, {
post() {
const { roomId } = this.bodyParams;
const { roomId, joiningNow = true } = this.bodyParams;
if (!roomId) {
return API.v1.failure('The "roomId" parameter is required!');
}
@ -15,7 +15,7 @@ API.v1.addRoute('video-conference/jitsi.update-timeout', { authRequired: true },
return API.v1.failure('Room does not exist!');
}
const jitsiTimeout = Meteor.runAsUser(this.userId, () => Meteor.call('jitsi:updateTimeout', roomId));
const jitsiTimeout = Meteor.runAsUser(this.userId, () => Meteor.call('jitsi:updateTimeout', roomId, Boolean(joiningNow)));
return API.v1.success({ jitsiTimeout });
},

@ -9,7 +9,7 @@ import { canSendMessage } from '../../../authorization/server';
import { SystemLogger } from '../../../logger/server';
Meteor.methods({
'jitsi:updateTimeout': (rid) => {
'jitsi:updateTimeout': (rid, joiningNow = true) => {
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'jitsi:updateTimeout' });
}
@ -36,7 +36,7 @@ Meteor.methods({
Rooms.setJitsiTimeout(rid, nextTimeOut);
}
if (!jitsiTimeout || currentTime > jitsiTimeout) {
if (joiningNow && (!jitsiTimeout || currentTime > jitsiTimeout)) {
metrics.messagesSent.inc(); // TODO This line needs to be moved to it's proper place. See the comments on: https://github.com/RocketChat/Rocket.Chat/pull/5736
const message = Messages.createWithTypeRoomIdMessageAndUser('jitsi_call_started', rid, '', Meteor.user(), {

@ -124,14 +124,14 @@ const CallJitsWithData = ({ rid }) => {
if (jitsi.window?.closed) {
return jitsi.dispose();
}
return updateTimeout(rid);
return updateTimeout(rid, false);
}
if (new Date() - new Date(room.jitsiTimeout) > TIMEOUT) {
return jitsi.dispose();
}
if (new Date() - new Date(room.jitsiTimeout) + TIMEOUT > DEBOUNCE) {
return updateTimeout(rid);
return updateTimeout(rid, false);
}
});
@ -139,9 +139,13 @@ const CallJitsWithData = ({ rid }) => {
if (!accepted || !jitsi) {
return;
}
jitsi.start(ref.current);
updateTimeout(rid);
if (jitsi.needsStart) {
jitsi.start(ref.current);
updateTimeout(rid, true);
} else {
updateTimeout(rid, false);
}
jitsi.on('HEARTBEAT', testAndHandleTimeout);
const none = () => {};
@ -154,7 +158,12 @@ const CallJitsWithData = ({ rid }) => {
}, [accepted, jitsi, rid, testAndHandleTimeout, updateTimeout]);
const handleYes = useMutableCallback(() => {
if (jitsi) {
jitsi.needsStart = true;
}
setAccepted(true);
if (openNewWindow) {
handleClose();
}

@ -18,9 +18,16 @@ export class JitsiBridge extends Emitter {
this.name = name;
this.heartbeat = heartbeat;
this.window = undefined;
this.needsStart = false;
}
start(domTarget) {
if (!this.needsStart) {
return;
}
this.needsStart = false;
const heartbeatTimer = setInterval(() => this.emit('HEARTBEAT', true), this.heartbeat);
this.once('dispose', () => clearTimeout(heartbeatTimer));
@ -66,6 +73,7 @@ export class JitsiBridge extends Emitter {
const width = 'auto';
const height = 500;
const api = new JitsiMeetExternalAPI(
domain,
jitsiRoomName,

Loading…
Cancel
Save