Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/api/server/v1/video-conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!');
}
Expand All @@ -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 });
},
Expand Down
4 changes: 2 additions & 2 deletions app/videobridge/server/methods/jitsiSetTimeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
}
Expand All @@ -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(), {
Expand Down
17 changes: 13 additions & 4 deletions client/views/room/contextualBar/Call/Jitsi/CallJitsWithData.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,24 +124,28 @@ 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);
}
});

useEffect(() => {
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 = () => {};
Expand All @@ -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();
}
Expand Down
8 changes: 8 additions & 0 deletions client/views/room/contextualBar/Call/Jitsi/lib/JitsiBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -66,6 +73,7 @@ export class JitsiBridge extends Emitter {

const width = 'auto';
const height = 500;

const api = new JitsiMeetExternalAPI(
domain,
jitsiRoomName,
Expand Down