[mirotalksfu] - fix rules
هذا الالتزام موجود في:
@@ -270,7 +270,7 @@ function startServer() {
|
|||||||
if (hostCfg.authenticated && Object.keys(req.query).length > 0) {
|
if (hostCfg.authenticated && Object.keys(req.query).length > 0) {
|
||||||
log.debug('Direct Join', req.query);
|
log.debug('Direct Join', req.query);
|
||||||
// http://localhost:3010/join?room=test&password=0&name=mirotalksfu&audio=1&video=1&screen=1¬ify=1
|
// http://localhost:3010/join?room=test&password=0&name=mirotalksfu&audio=1&video=1&screen=1¬ify=1
|
||||||
const { room, password, name, audio, video, screen, notify } = checkXSS(req.query);
|
const { room, password, name, audio, video, screen, notify, isPresenter } = checkXSS(req.query);
|
||||||
if (room && password && name && audio && video && screen && notify) {
|
if (room && password && name && audio && video && screen && notify) {
|
||||||
return res.sendFile(views.room);
|
return res.sendFile(views.room);
|
||||||
}
|
}
|
||||||
@@ -1018,10 +1018,14 @@ function startServer() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('disconnect', () => {
|
socket.on('disconnect', async () => {
|
||||||
if (!roomList.has(socket.room_id)) return;
|
if (!roomList.has(socket.room_id)) return;
|
||||||
|
|
||||||
log.debug('Disconnect', getPeerName());
|
const peerName = roomList.get(socket.room_id).getPeers()?.get(socket.id)?.peer_info?.peer_name;
|
||||||
|
const peerUuid = roomList.get(socket.room_id).getPeers()?.get(socket.id)?.peer_info?.peer_uuid;
|
||||||
|
const isPresenter = await isPeerPresenter(socket.room_id, peerName, peerUuid);
|
||||||
|
|
||||||
|
log.debug('Disconnect', peerName);
|
||||||
|
|
||||||
roomList.get(socket.room_id).removePeer(socket.id);
|
roomList.get(socket.room_id).removePeer(socket.id);
|
||||||
|
|
||||||
@@ -1036,7 +1040,7 @@ function startServer() {
|
|||||||
log.debug('Disconnect - current presenters grouped by roomId', presenters);
|
log.debug('Disconnect - current presenters grouped by roomId', presenters);
|
||||||
}
|
}
|
||||||
|
|
||||||
roomList.get(socket.room_id).broadCast(socket.id, 'removeMe', removeMeData());
|
roomList.get(socket.room_id).broadCast(socket.id, 'removeMe', removeMeData(peerName, isPresenter));
|
||||||
|
|
||||||
removeIP(socket);
|
removeIP(socket);
|
||||||
});
|
});
|
||||||
@@ -1047,12 +1051,17 @@ function startServer() {
|
|||||||
error: 'Not currently in a room',
|
error: 'Not currently in a room',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
log.debug('Exit room', getPeerName());
|
|
||||||
|
const peerName = roomList.get(socket.room_id).getPeers()?.get(socket.id)?.peer_info?.peer_name;
|
||||||
|
const peerUuid = roomList.get(socket.room_id).getPeers()?.get(socket.id)?.peer_info?.peer_uuid;
|
||||||
|
const isPresenter = await isPeerPresenter(socket.room_id, peerName, peerUuid);
|
||||||
|
|
||||||
|
log.debug('Exit room', peerName);
|
||||||
|
|
||||||
// close transports
|
// close transports
|
||||||
await roomList.get(socket.room_id).removePeer(socket.id);
|
await roomList.get(socket.room_id).removePeer(socket.id);
|
||||||
|
|
||||||
roomList.get(socket.room_id).broadCast(socket.id, 'removeMe', removeMeData());
|
roomList.get(socket.room_id).broadCast(socket.id, 'removeMe', removeMeData(peerName, isPresenter));
|
||||||
|
|
||||||
if (roomList.get(socket.room_id).getPeers().size === 0) {
|
if (roomList.get(socket.room_id).getPeers().size === 0) {
|
||||||
roomList.delete(socket.room_id);
|
roomList.delete(socket.room_id);
|
||||||
@@ -1111,11 +1120,20 @@ function startServer() {
|
|||||||
return pattern.test(input);
|
return pattern.test(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeMeData() {
|
function removeMeData(peerName, isPresenter) {
|
||||||
|
const roomId = roomList.get(socket.room_id) && socket.room_id;
|
||||||
|
const peerCounts = roomList.get(socket.room_id) && roomList.get(socket.room_id).getPeers().size;
|
||||||
|
log.debug('REMOVE ME DATA', {
|
||||||
|
roomId: roomId,
|
||||||
|
name: peerName,
|
||||||
|
isPresenter: isPresenter,
|
||||||
|
count: peerCounts,
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
room_id: roomList.get(socket.room_id) && socket.room_id,
|
room_id: roomId,
|
||||||
peer_id: socket.id,
|
peer_id: socket.id,
|
||||||
peer_counts: roomList.get(socket.room_id) && roomList.get(socket.room_id).getPeers().size,
|
peer_counts: peerCounts,
|
||||||
|
isPresenter: isPresenter,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ let peer_name = getPeerName();
|
|||||||
let peer_uuid = getPeerUUID();
|
let peer_uuid = getPeerUUID();
|
||||||
let isScreenAllowed = getScreen();
|
let isScreenAllowed = getScreen();
|
||||||
let notify = getNotify();
|
let notify = getNotify();
|
||||||
|
isPresenter = isPeerPresenter();
|
||||||
|
|
||||||
let peer_info = null;
|
let peer_info = null;
|
||||||
|
|
||||||
@@ -412,6 +413,21 @@ function getNotify() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isPeerPresenter() {
|
||||||
|
let qs = new URLSearchParams(window.location.search);
|
||||||
|
let presenter = filterXSS(qs.get('isPresenter'));
|
||||||
|
if (presenter) {
|
||||||
|
presenter = presenter.toLowerCase();
|
||||||
|
let queryPresenter = presenter === '1' || presenter === 'true';
|
||||||
|
if (queryPresenter != null) {
|
||||||
|
console.log('Direct join Reconnect', { isPresenter: queryPresenter });
|
||||||
|
return queryPresenter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('Direct join Reconnect', { presenter: true });
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function getPeerName() {
|
function getPeerName() {
|
||||||
const qs = new URLSearchParams(window.location.search);
|
const qs = new URLSearchParams(window.location.search);
|
||||||
const name = filterXSS(qs.get('name'));
|
const name = filterXSS(qs.get('name'));
|
||||||
|
|||||||
@@ -318,7 +318,8 @@ class RoomClient {
|
|||||||
for (let peer of Array.from(peers.keys()).filter((id) => id == this.peer_id)) {
|
for (let peer of Array.from(peers.keys()).filter((id) => id == this.peer_id)) {
|
||||||
let my_peer_info = peers.get(peer).peer_info;
|
let my_peer_info = peers.get(peer).peer_info;
|
||||||
console.log('07.1 ----> My Peer info', my_peer_info);
|
console.log('07.1 ----> My Peer info', my_peer_info);
|
||||||
isPresenter = my_peer_info.peer_presenter;
|
isPresenter = window.localStorage.isReconnected === 'true' ? isPresenter : my_peer_info.peer_presenter;
|
||||||
|
window.localStorage.isReconnected = false;
|
||||||
handleRules(isPresenter);
|
handleRules(isPresenter);
|
||||||
}
|
}
|
||||||
adaptAspectRatio(participantsCount);
|
adaptAspectRatio(participantsCount);
|
||||||
@@ -521,11 +522,6 @@ class RoomClient {
|
|||||||
participantsCount = data.peer_counts;
|
participantsCount = data.peer_counts;
|
||||||
adaptAspectRatio(participantsCount);
|
adaptAspectRatio(participantsCount);
|
||||||
if (isParticipantsListOpen) getRoomParticipants(true);
|
if (isParticipantsListOpen) getRoomParticipants(true);
|
||||||
if (participantsCount == 1) {
|
|
||||||
isPresenter = true;
|
|
||||||
handleRules(isPresenter);
|
|
||||||
console.log('I am alone in the room, got Presenter Rules');
|
|
||||||
}
|
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -664,7 +660,7 @@ class RoomClient {
|
|||||||
console.log('Connected to signaling server!');
|
console.log('Connected to signaling server!');
|
||||||
this._isConnected = true;
|
this._isConnected = true;
|
||||||
// location.reload();
|
// location.reload();
|
||||||
getPeerName() ? location.reload() : openURL(this.getDirectJoinURL());
|
getPeerName() ? location.reload() : openURL(this.getReconnectDirectJoinURL());
|
||||||
}.bind(this),
|
}.bind(this),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -683,6 +679,7 @@ class RoomClient {
|
|||||||
|
|
||||||
ServerAway() {
|
ServerAway() {
|
||||||
this.sound('alert');
|
this.sound('alert');
|
||||||
|
window.localStorage.isReconnected = true;
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
allowOutsideClick: false,
|
allowOutsideClick: false,
|
||||||
allowEscapeKey: false,
|
allowEscapeKey: false,
|
||||||
@@ -702,8 +699,8 @@ class RoomClient {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getDirectJoinURL() {
|
getReconnectDirectJoinURL() {
|
||||||
return `${window.location.origin}/join?room=${this.room_id}&password=${this.RoomPassword}&name=${this.peer_name}&audio=${this.peer_info.peer_audio}&video=${this.peer_info.peer_video}&screen=${this.peer_info.peer_screen}¬ify=0`;
|
return `${window.location.origin}/join?room=${this.room_id}&password=${this.RoomPassword}&name=${this.peer_name}&audio=${this.peer_info.peer_audio}&video=${this.peer_info.peer_video}&screen=${this.peer_info.peer_screen}¬ify=0&isPresenter=${isPresenter}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ####################################################
|
// ####################################################
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم