Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable30] fix(federation): Send newest state of the changed properties when ret… #13424

Merged
merged 2 commits into from
Sep 30, 2024
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
49 changes: 48 additions & 1 deletion lib/Federation/BackendNotifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
19 changes: 13 additions & 6 deletions tests/integration/features/command/user-remove.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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)
Expand Down
Loading