Skip to content

Commit

Permalink
fix: Notify "roomlist" updates to federated users
Browse files Browse the repository at this point in the history
When a participant is invited or disinvited to a conversation, or a
session is removed, the affected user receives a "roomlist" message with
type "invite" or "disinvite", while the rest of users in the
conversation receive a "roomlist" message with type "update" and a
"participant-list: refresh" property. Now both federated users and local
users receive the "roomlist" update.

Local users are also notified with a "roomlist" update when the
properties of the room change. However, in that case the signaling
server of federated users will be notified by the federated Nextcloud
server when the property changes are propagated to it, so there is no
need to notify federated users from the remote Nextcloud server in that
case.

Note, however, that independently of the users explicitly notified with
the "userids" parameter (which can include inactive participants) that
receive the "roomlist" message, the signaling server automatically
notifies all active participants in a conversation when it is modified,
so active federated users will receive a "room" message with the updated
properties (which may never be reflected in the proxy conversation, as
some properties are not propagated to the federated conversations).

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
  • Loading branch information
danxuliu committed Jul 22, 2024
1 parent 19cc30e commit 1857b84
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/Service/ParticipantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1622,6 +1622,13 @@ public function getParticipantUserIds(Room $room, ?\DateTime $maxLastJoined = nu
return $this->getParticipantActorIdsByActorType($room, Attendee::ACTOR_USERS, $maxLastJoined);
}

/**
* @return string[]
*/
public function getFederatedParticipantCloudIds(Room $room, ?\DateTime $maxLastJoined = null): array {
return $this->getParticipantActorIdsByActorType($room, Attendee::ACTOR_FEDERATED_USERS, $maxLastJoined);
}

/**
* @return string[]
*/
Expand Down
9 changes: 8 additions & 1 deletion lib/Signaling/BackendNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ private function backendRequest(Room $room, array $data): ?IResponse {
* @throws \Exception
*/
public function roomInvited(Room $room, array $attendees): void {
$allUserIds = $this->participantService->getParticipantUserIds($room);
$allUserIds = array_merge($allUserIds, $this->participantService->getFederatedParticipantCloudIds($room));
$userIds = [];
foreach ($attendees as $attendee) {
if ($attendee->getActorType() === Attendee::ACTOR_USERS) {
Expand All @@ -155,7 +157,7 @@ public function roomInvited(Room $room, array $attendees): void {
'userids' => $userIds,
// TODO(fancycode): We should try to get rid of 'alluserids' and
// find a better way to notify existing users to update the room.
'alluserids' => $this->participantService->getParticipantUserIds($room),
'alluserids' => $allUserIds,
'properties' => $room->getPropertiesForSignaling('', false),
],
]);
Expand All @@ -177,6 +179,7 @@ public function roomInvited(Room $room, array $attendees): void {
*/
public function roomsDisinvited(Room $room, array $attendees): void {
$allUserIds = $this->participantService->getParticipantUserIds($room);
$allUserIds = array_merge($allUserIds, $this->participantService->getFederatedParticipantCloudIds($room));
sort($allUserIds);
$userIds = [];
foreach ($attendees as $attendee) {
Expand Down Expand Up @@ -213,6 +216,7 @@ public function roomsDisinvited(Room $room, array $attendees): void {
*/
public function roomSessionsRemoved(Room $room, array $sessionIds): void {
$allUserIds = $this->participantService->getParticipantUserIds($room);
$allUserIds = array_merge($allUserIds, $this->participantService->getFederatedParticipantCloudIds($room));
sort($allUserIds);
$start = microtime(true);
$this->backendRequest($room, [
Expand Down Expand Up @@ -245,6 +249,9 @@ public function roomModified(Room $room): void {
$this->backendRequest($room, [
'type' => 'update',
'update' => [
// Message not sent for federated users, as they will receive
// the message from their federated Nextcloud server once the
// property change is propagated.
'userids' => $this->participantService->getParticipantUserIds($room),
'properties' => $room->getPropertiesForSignaling(''),
],
Expand Down

0 comments on commit 1857b84

Please sign in to comment.