From 13e807885b67c95c8b156ff48bb5982a02b91035 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 30 Sep 2024 17:46:23 +0200 Subject: [PATCH 1/2] fix(federation): Send newest state of the changed properties when retrying OCM Signed-off-by: Joas Schilling --- lib/Federation/BackendNotifier.php | 49 +++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/lib/Federation/BackendNotifier.php b/lib/Federation/BackendNotifier.php index db891f07c92..1624866e6f8 100644 --- a/lib/Federation/BackendNotifier.php +++ b/lib/Federation/BackendNotifier.php @@ -10,10 +10,14 @@ use OCA\FederatedFileSharing\AddressHandler; use OCA\Talk\Events\AParticipantModifiedEvent; +use OCA\Talk\Events\ARoomModifiedEvent; use OCA\Talk\Exceptions\RoomHasNoModeratorException; +use OCA\Talk\Exceptions\RoomNotFoundException; +use OCA\Talk\Manager; use OCA\Talk\Model\Attendee; use OCA\Talk\Model\RetryNotification; use OCA\Talk\Model\RetryNotificationMapper; +use OCA\Talk\Participant; use OCA\Talk\Room; use OCP\AppFramework\Http; use OCP\AppFramework\Utility\ITimeFactory; @@ -494,12 +498,55 @@ public function retrySendingFailedNotifications(\DateTimeInterface $dueDateTime) } protected function retrySendingFailedNotification(RetryNotification $retryNotification): void { + $data = json_decode($retryNotification->getNotification(), true, flags: JSON_THROW_ON_ERROR); + if ($retryNotification->getNotificationType() === FederationManager::NOTIFICATION_ROOM_MODIFIED) { + $localToken = $data['remoteToken']; + + try { + $manager = \OCP\Server::get(Manager::class); + $room = $manager->getRoomByToken($localToken); + } catch (RoomNotFoundException) { + // Room was deleted in the meantime + return; + } + + if ($data['changedProperty'] === ARoomModifiedEvent::PROPERTY_LOBBY) { + $dateTime = $room->getLobbyTimer(); + $data['newValue'] = $room->getLobbyState(); + $data['dateTime'] = (string)$dateTime?->getTimestamp(); + } elseif ($data['changedProperty'] === ARoomModifiedEvent::PROPERTY_ACTIVE_SINCE) { + if ($room->getActiveSince() === null) { + $data['newValue'] = null; + $data['callFlag'] = Participant::FLAG_DISCONNECTED; + } else { + $data['newValue'] = $room->getActiveSince()->getTimestamp(); + $data['callFlag'] = $room->getCallFlag(); + } + } else { + $data['newValue'] = match ($data['changedProperty']) { + ARoomModifiedEvent::PROPERTY_AVATAR => $room->getAvatar(), + ARoomModifiedEvent::PROPERTY_CALL_RECORDING => $room->getCallRecording(), + ARoomModifiedEvent::PROPERTY_DEFAULT_PERMISSIONS => $room->getDefaultPermissions(), + ARoomModifiedEvent::PROPERTY_DESCRIPTION => $room->getDescription(), + ARoomModifiedEvent::PROPERTY_IN_CALL => $room->getCallFlag(), + ARoomModifiedEvent::PROPERTY_MENTION_PERMISSIONS => $room->getMentionPermissions(), + ARoomModifiedEvent::PROPERTY_MESSAGE_EXPIRATION => $room->getMessageExpiration(), + ARoomModifiedEvent::PROPERTY_NAME => $room->getName(), + ARoomModifiedEvent::PROPERTY_READ_ONLY => $room->getReadOnly(), + ARoomModifiedEvent::PROPERTY_RECORDING_CONSENT => $room->getRecordingConsent(), + ARoomModifiedEvent::PROPERTY_SIP_ENABLED => $room->getSIPEnabled(), + ARoomModifiedEvent::PROPERTY_TYPE => $room->getType(), + default => $data['newValue'], + }; + } + } + $notification = $this->cloudFederationFactory->getCloudFederationNotification(); $notification->setMessage( $retryNotification->getNotificationType(), $retryNotification->getResourceType(), $retryNotification->getProviderId(), - json_decode($retryNotification->getNotification(), true, flags: JSON_THROW_ON_ERROR), + $data, ); $success = $this->sendUpdateToRemote($retryNotification->getRemoteServer(), $notification, $retryNotification->getNumAttempts()); From e70d5541e90c7de8c5df195534405dc5e0622b82 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 30 Sep 2024 21:57:23 +0200 Subject: [PATCH 2/2] ci: Try to make the missed call test more reliable Signed-off-by: Joas Schilling --- .../features/command/user-remove.feature | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/integration/features/command/user-remove.feature b/tests/integration/features/command/user-remove.feature index f6d1d87d976..6e1ea86cc40 100644 --- a/tests/integration/features/command/user-remove.feature +++ b/tests/integration/features/command/user-remove.feature @@ -67,11 +67,18 @@ Feature: command/user-remove Given user "participant1" creates room "room" (v4) | roomType | 1 | | invite | participant2 | - Then user "participant1" joins room "room" with 200 (v4) - Then user "participant1" joins call "room" with 200 (v4) - Then user "participant1" leaves call "room" with 200 (v4) - Then user "participant1" leaves room "room" with 200 (v4) - And reset signaling server requests + When user "participant1" joins room "room" with 200 (v4) + And user "participant1" joins call "room" with 200 (v4) + And wait for 1 second + And user "participant1" leaves call "room" with 200 (v4) + And user "participant1" leaves room "room" with 200 (v4) + Then user "participant1" sees the following system messages in room "room" with 200 + | room | actorType | actorId | systemMessage | message | messageParameters | + | room | users | participant1 | call_tried | You tried to call {user} | {"user":{"type":"user","id":"participant2","name":"participant2-displayname"}} | + | room | users | participant1 | call_left | You left the call | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | + | room | users | participant1 | call_started | You started a call | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | + | room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} | + When reset signaling server requests And invoking occ with "talk:user:remove --user participant2" Then signaling server received the following requests | token | data | @@ -83,7 +90,7 @@ Feature: command/user-remove | room | {"type":"message","message":{"data":{"type":"chat","chat":{"refresh":true}}}} | # Read only changed | room | {"type":"update","update":{"userids":["participant1"],"properties":{"name":"Private conversation","type":5,"lobby-state":0,"lobby-timer":null,"read-only":1,"listable":0,"active-since":null,"sip-enabled":0,"description":""}}} | - And the command output contains the text "Users successfully removed from all rooms" + And the command output contains the text "Users successfully removed from all rooms" Then the command was successful And user "participant2" is participant of the following rooms (v4) And user "participant1" is participant of the following rooms (v4)