Skip to content

Commit fc1fa68

Browse files
committed
feat(signaling): Don't send all room userids in signaling server requests
Signed-off-by: Joachim Bauch <bauch@struktur.de>
1 parent 433651f commit fc1fa68

File tree

2 files changed

+15
-33
lines changed

2 files changed

+15
-33
lines changed

lib/Signaling/BackendNotifier.php

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ public function roomInvited(Room $room, array $attendees): void {
152152
$userIds[] = $attendee->getActorId();
153153
}
154154
}
155+
if (empty($userIds)) {
156+
return;
157+
}
155158
$start = microtime(true);
156159
$this->backendRequest($room, [
157160
'type' => 'invite',
158161
'invite' => [
159162
'userids' => $userIds,
160-
// TODO(fancycode): We should try to get rid of 'alluserids' and
161-
// find a better way to notify existing users to update the room.
162-
'alluserids' => $this->participantService->getParticipantUserIdsAndFederatedUserCloudIds($room),
163163
'properties' => $room->getPropertiesForSignaling('', false),
164164
],
165165
]);
@@ -180,22 +180,20 @@ public function roomInvited(Room $room, array $attendees): void {
180180
* @throws \Exception
181181
*/
182182
public function roomsDisinvited(Room $room, array $attendees): void {
183-
$allUserIds = $this->participantService->getParticipantUserIdsAndFederatedUserCloudIds($room);
184-
sort($allUserIds);
185183
$userIds = [];
186184
foreach ($attendees as $attendee) {
187185
if ($attendee->getActorType() === Attendee::ACTOR_USERS) {
188186
$userIds[] = $attendee->getActorId();
189187
}
190188
}
189+
if (empty($userIds)) {
190+
return;
191+
}
191192
$start = microtime(true);
192193
$this->backendRequest($room, [
193194
'type' => 'disinvite',
194195
'disinvite' => [
195196
'userids' => $userIds,
196-
// TODO(fancycode): We should try to get rid of 'alluserids' and
197-
// find a better way to notify existing users to update the room.
198-
'alluserids' => $allUserIds,
199197
'properties' => $room->getPropertiesForSignaling('', false),
200198
],
201199
]);
@@ -216,16 +214,11 @@ public function roomsDisinvited(Room $room, array $attendees): void {
216214
* @throws \Exception
217215
*/
218216
public function roomSessionsRemoved(Room $room, array $sessionIds): void {
219-
$allUserIds = $this->participantService->getParticipantUserIdsAndFederatedUserCloudIds($room);
220-
sort($allUserIds);
221217
$start = microtime(true);
222218
$this->backendRequest($room, [
223219
'type' => 'disinvite',
224220
'disinvite' => [
225221
'sessionids' => $sessionIds,
226-
// TODO(fancycode): We should try to get rid of 'alluserids' and
227-
// find a better way to notify existing users to update the room.
228-
'alluserids' => $allUserIds,
229222
'properties' => $room->getPropertiesForSignaling('', false),
230223
],
231224
]);
@@ -249,10 +242,6 @@ public function roomModified(Room $room): void {
249242
$this->backendRequest($room, [
250243
'type' => 'update',
251244
'update' => [
252-
// Message not sent for federated users, as they will receive
253-
// the message from their federated Nextcloud server once the
254-
// property change is propagated.
255-
'userids' => $this->participantService->getParticipantUserIds($room),
256245
'properties' => $room->getPropertiesForSignaling(''),
257246
],
258247
]);
@@ -271,13 +260,11 @@ public function roomModified(Room $room): void {
271260
* @param string[] $userIds
272261
* @throws \Exception
273262
*/
274-
public function roomDeleted(Room $room, array $userIds): void {
263+
public function roomDeleted(Room $room): void {
275264
$start = microtime(true);
276265
$this->backendRequest($room, [
277266
'type' => 'delete',
278-
'delete' => [
279-
'userids' => $userIds,
280-
],
267+
'delete' => (object)[],
281268
]);
282269
$duration = microtime(true) - $start;
283270
$this->logger->debug('Room deleted: {token} ({duration})', [
@@ -323,7 +310,6 @@ public function switchToRoom(Room $room, string $switchToRoomToken, array $sessi
323310
*/
324311
public function participantsModified(Room $room, array $sessionIds): void {
325312
$changed = [];
326-
$users = [];
327313
$participants = $this->participantService->getSessionsAndParticipantsForRoom($room);
328314
foreach ($participants as $participant) {
329315
$attendee = $participant->getAttendee();
@@ -354,7 +340,6 @@ public function participantsModified(Room $room, array $sessionIds): void {
354340
$data['lastPing'] = $session->getLastPing();
355341
$data['sessionId'] = $session->getSessionId();
356342
$data['participantPermissions'] = $participant->getPermissions();
357-
$users[] = $data;
358343

359344
if (\in_array($session->getSessionId(), $sessionIds, true)) {
360345
$data['permissions'] = [];
@@ -372,17 +357,17 @@ public function participantsModified(Room $room, array $sessionIds): void {
372357
}
373358
$changed[] = $data;
374359
}
375-
} else {
376-
$users[] = $data;
377360
}
378361
}
379362

363+
if (empty($changed)) {
364+
return;
365+
}
380366
$start = microtime(true);
381367
$this->backendRequest($room, [
382368
'type' => 'participants',
383369
'participants' => [
384370
'changed' => $changed,
385-
'users' => $users
386371
],
387372
]);
388373
$duration = microtime(true) - $start;
@@ -411,7 +396,6 @@ public function roomInCallChanged(Room $room, int $flags, array $sessionIds, boo
411396
];
412397
} else {
413398
$changed = [];
414-
$users = [];
415399

416400
$participants = $this->participantService->getParticipantsForAllSessions($room);
417401
foreach ($participants as $participant) {
@@ -442,19 +426,17 @@ public function roomInCallChanged(Room $room, int $flags, array $sessionIds, boo
442426
$data['userId'] = $attendee->getActorId();
443427
}
444428

445-
if ($session->getInCall() !== Participant::FLAG_DISCONNECTED) {
446-
$users[] = $data;
447-
}
448-
449429
if (\in_array($session->getSessionId(), $sessionIds, true)) {
450430
$changed[] = $data;
451431
}
452432
}
453433

434+
if (empty($changed)) {
435+
return;
436+
}
454437
$data = [
455438
'incall' => $flags,
456439
'changed' => $changed,
457-
'users' => $users,
458440
];
459441
}
460442

lib/Signaling/Listener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ protected function notifyCallEndedForEveryone(CallEndedForEveryoneEvent $event):
263263

264264
protected function notifyBeforeRoomDeleted(BeforeRoomDeletedEvent $event): void {
265265
$room = $event->getRoom();
266-
$this->externalSignaling->roomDeleted($room, $this->participantService->getParticipantUserIds($room));
266+
$this->externalSignaling->roomDeleted($room);
267267
}
268268

269269
protected function notifyGuestsCleanedUp(GuestsCleanedUpEvent $event): void {

0 commit comments

Comments
 (0)