summaryrefslogtreecommitdiffstats
path: root/lib/Federation/BackendNotifier.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-10-18 17:04:59 +0200
committerJoas Schilling <coding@schilljs.com>2023-10-27 08:49:00 +0200
commitef3fe8fa7e7941717d19d47edbba7481fbcb60b9 (patch)
treecfcc178517564e52bff4bc3dd290247f3cf27ecd /lib/Federation/BackendNotifier.php
parent4d54c281f8d7daf81523d46c97426b3231a9c968 (diff)
feat(federation): Send room modifications via OCM notifications to remotes
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Federation/BackendNotifier.php')
-rw-r--r--lib/Federation/BackendNotifier.php41
1 files changed, 39 insertions, 2 deletions
diff --git a/lib/Federation/BackendNotifier.php b/lib/Federation/BackendNotifier.php
index 46de8f4e1..a50759e03 100644
--- a/lib/Federation/BackendNotifier.php
+++ b/lib/Federation/BackendNotifier.php
@@ -40,6 +40,7 @@ use OCP\HintException;
use OCP\IUser;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;
+use SensitiveParameter;
class BackendNotifier {
@@ -192,6 +193,42 @@ class BackendNotifier {
$this->sendUpdateToRemote($remote, $notification);
}
+ public function sendRoomModifiedUpdate(
+ string $remoteServer,
+ int $localAttendeeId,
+ #[SensitiveParameter]
+ string $accessToken,
+ string $localToken,
+ string $changedProperty,
+ string|int|bool|null $newValue,
+ string|int|bool|null $oldValue,
+ ): void {
+ $remote = $this->prepareRemoteUrl($remoteServer);
+
+ $notification = $this->cloudFederationFactory->getCloudFederationNotification();
+ $notification->setMessage(
+ FederationManager::NOTIFICATION_ROOM_MODIFIED,
+ FederationManager::TALK_ROOM_RESOURCE,
+ (string) $localAttendeeId,
+ [
+ 'sharedSecret' => $accessToken,
+ 'remoteToken' => $localToken,
+ 'changedProperty' => $changedProperty,
+ 'newValue' => $newValue,
+ 'oldValue' => $oldValue,
+ ],
+ );
+
+ $this->sendUpdateToRemote($remote, $notification);
+ }
+
+ /**
+ * @internal Used to send retries in background jobs
+ * @param string $remote
+ * @param array $data
+ * @param int $try
+ * @return void
+ */
public function sendUpdateDataToRemote(string $remote, array $data = [], int $try = 0): void {
$notification = $this->cloudFederationFactory->getCloudFederationNotification();
$notification->setMessage(
@@ -203,7 +240,7 @@ class BackendNotifier {
$this->sendUpdateToRemote($remote, $notification, $try);
}
- public function sendUpdateToRemote(string $remote, ICloudFederationNotification $notification, int $try = 0): void {
+ protected function sendUpdateToRemote(string $remote, ICloudFederationNotification $notification, int $try = 0): void {
$response = $this->federationProviderManager->sendNotification($remote, $notification);
if (!is_array($response)) {
$this->jobList->add(RetryJob::class,
@@ -216,7 +253,7 @@ class BackendNotifier {
}
}
- private function prepareRemoteUrl(string $remote): string {
+ protected function prepareRemoteUrl(string $remote): string {
if (!$this->addressHandler->urlContainProtocol($remote)) {
return 'https://' . $remote;
}