From 1acf4610d7e154db545d88ec781a000a645f75e3 Mon Sep 17 00:00:00 2001 From: Tiavina Date: Tue, 25 Mar 2025 17:38:47 +0300 Subject: [PATCH] Add null check for roomToken before processing attachments in GestionService --- gestion/lib/Service/GestionService.php | 30 +++++++++++++++----------- gestion/lib/Service/TalkService.php | 2 +- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/gestion/lib/Service/GestionService.php b/gestion/lib/Service/GestionService.php index 030f581..7f9e14e 100644 --- a/gestion/lib/Service/GestionService.php +++ b/gestion/lib/Service/GestionService.php @@ -249,12 +249,14 @@ class GestionService { } }else { $roomToken = $this->talkService->getRoomTokenBeetwenTwoUser($this->userConnectedUuid, $userName); - foreach ( $attachments as $attachment) { - $this->userConnectedStorage->getFullPath("/"); - $path = Filesystem::getPath($attachment['file_id']); - $destination = 'Talk/'; - Filesystem::copy($path, $destination . $attachment['name']); - $this->sendFileAttachmentToTalk($roomToken,$cookie , $attachment['name']); + if($roomToken != null){ + foreach ( $attachments as $attachment) { + $this->userConnectedStorage->getFullPath("/"); + $path = Filesystem::getPath($attachment['file_id']); + $destination = 'Talk/'; + Filesystem::copy($path, $destination . $attachment['name']); + $this->sendFileAttachmentToTalk($roomToken,$cookie , $attachment['name']); + } } } @@ -408,13 +410,15 @@ class GestionService { }else{ $roomToken = $this->talkService->getRoomTokenBeetwenTwoUser($this->userConnectedUuid, $userName); - foreach ( $attachments as $attachment) { - $this->userConnectedStorage->getFullPath("/"); - $path = Filesystem::getPath($attachment['file_id']); - $destination = 'Talk/'; - Filesystem::copy($path, $destination . $attachment['name']); - //sendFileAttachmentToTalk - $this->sendFileAttachmentToTalk($roomToken,$cookie , $attachment['name']); + if($roomToken != null){ + foreach ( $attachments as $attachment) { + $this->userConnectedStorage->getFullPath("/"); + $path = Filesystem::getPath($attachment['file_id']); + $destination = 'Talk/'; + Filesystem::copy($path, $destination . $attachment['name']); + //sendFileAttachmentToTalk + $this->sendFileAttachmentToTalk($roomToken,$cookie , $attachment['name']); + } } } diff --git a/gestion/lib/Service/TalkService.php b/gestion/lib/Service/TalkService.php index 20c70b0..504fb56 100644 --- a/gestion/lib/Service/TalkService.php +++ b/gestion/lib/Service/TalkService.php @@ -107,7 +107,7 @@ class TalkService { $senderAndTargetIsTheSameUser = $targetUser == $senderUser; $senderUser = $senderAndTargetIsTheSameUser ? BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD : $senderUser; if( $targetUser === BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD && $senderUser === BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD){ - return; + return null; } $roomNames = $this->getUserDevisTalkRoomNames($targetUser , $senderUser); $room = $this->talkDb->getDevisTalkRoomByNames($roomNames);