diff options
author | Joas Schilling <coding@schilljs.com> | 2024-03-15 09:46:13 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2024-03-15 10:00:14 +0100 |
commit | 30d5e7c3ab9fa2bace6d50f570042d546a626a7a (patch) | |
tree | 131d15b58fa91a30578e28b78099c79f9bff2513 /lib/Federation/CloudFederationProviderTalk.php | |
parent | 710f2c26ea6a9b977b87f49b530dbc15ef34b1ec (diff) |
fix(notifications): Fix federated users being authors of notifications
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Federation/CloudFederationProviderTalk.php')
-rw-r--r-- | lib/Federation/CloudFederationProviderTalk.php | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/Federation/CloudFederationProviderTalk.php b/lib/Federation/CloudFederationProviderTalk.php index a17cb402e..43552b349 100644 --- a/lib/Federation/CloudFederationProviderTalk.php +++ b/lib/Federation/CloudFederationProviderTalk.php @@ -345,6 +345,19 @@ class CloudFederationProviderTalk implements ICloudFederationProvider { throw new ShareNotFound(FederationManager::OCM_RESOURCE_NOT_FOUND); } + // We transform the parameters when storing in the PCM, so we only have + // to do it once for each message. + // Note: `messageParameters` (array during parsing) vs `messageParameter` (string during sending) + $notification['messageData']['messageParameters'] = json_decode($notification['messageData']['messageParameter'], true, flags: JSON_THROW_ON_ERROR); + unset($notification['messageData']['messageParameter']); + $converted = $this->userConverter->convertMessage($room, $notification['messageData']); + $converted['messageParameter'] = json_encode($converted['messageParameters'], JSON_THROW_ON_ERROR); + unset($converted['messageParameters']); + + /** @var array{remoteMessageId: int, actorType: string, actorId: string, actorDisplayName: string, messageType: string, systemMessage: string, expirationDatetime: string, message: string, messageParameter: string, creationDatetime: string, metaData: string} $converted */ + $notification['messageData'] = $converted; + + $message = new ProxyCacheMessage(); $message->setLocalToken($room->getToken()); $message->setRemoteServerUrl($notification['remoteServerUrl']); @@ -358,16 +371,6 @@ class CloudFederationProviderTalk implements ICloudFederationProvider { if ($notification['messageData']['expirationDatetime']) { $message->setExpirationDatetime(new \DateTime($notification['messageData']['expirationDatetime'])); } - - // We transform the parameters when storing in the PCM, so we only have - // to do it once for each message. - $convertedParameters = $this->userConverter->convertMessageParameters($room, [ - 'message' => $notification['messageData']['message'], - 'messageParameters' => json_decode($notification['messageData']['messageParameter'], true, flags: JSON_THROW_ON_ERROR), - ]); - $notification['messageData']['message'] = $convertedParameters['message']; - $notification['messageData']['messageParameter'] = json_encode($convertedParameters['messageParameters'], JSON_THROW_ON_ERROR); - $message->setMessage($notification['messageData']['message']); $message->setMessageParameters($notification['messageData']['messageParameter']); $message->setCreationDatetime(new \DateTime($notification['messageData']['creationDatetime'])); |