summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-08-17 13:55:05 +0200
committerJoas Schilling <coding@schilljs.com>2022-08-17 14:20:11 +0200
commit17d3124dd85de474160106241c55970ad973e15c (patch)
treefda62dedcbbf0fd8c55c42ab1629b1160f94ae9e /lib
parent5871010f430c9775b1a20ad0feb249f3f2675301 (diff)
Delay getting the node until we know that we use the data
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Chat/Parser/SystemMessage.php31
1 files changed, 18 insertions, 13 deletions
diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php
index 51666142d..9cd88747f 100644
--- a/lib/Chat/Parser/SystemMessage.php
+++ b/lib/Chat/Parser/SystemMessage.php
@@ -570,16 +570,12 @@ class SystemMessage {
*/
protected function getFileFromShare(Participant $participant, string $shareId): array {
$share = $this->shareProvider->getShareById($shareId);
- $node = $share->getNode();
- $name = $node->getName();
- $size = $node->getSize();
- $path = $name;
if (!$participant->isGuest()) {
if ($share->getShareOwner() !== $participant->getAttendee()->getActorId()) {
$userFolder = $this->rootFolder->getUserFolder($participant->getAttendee()->getActorId());
if ($userFolder instanceof Node) {
- $userNodes = $userFolder->getById($node->getId());
+ $userNodes = $userFolder->getById($share->getNodeId());
if (empty($userNodes)) {
// FIXME This should be much more sensible, e.g.
@@ -587,31 +583,40 @@ class SystemMessage {
// 2. Once per request
\OC_Util::tearDownFS();
\OC_Util::setupFS($participant->getAttendee()->getActorId());
- $userNodes = $userFolder->getById($node->getId());
+ $userNodes = $userFolder->getById($share->getNodeId());
}
if (empty($userNodes)) {
throw new NotFoundException('File was not found');
}
- /** @var Node $userNode */
- $userNode = reset($userNodes);
- $fullPath = $userNode->getPath();
+ /** @var Node $node */
+ $node = reset($userNodes);
+ $fullPath = $node->getPath();
$pathSegments = explode('/', $fullPath, 4);
- $name = $userNode->getName();
- $size = $userNode->getSize();
- $path = $pathSegments[3] ?? $path;
+ $name = $node->getName();
+ $size = $node->getSize();
+ $path = $pathSegments[3] ?? $name;
}
} else {
+ $node = $share->getNode();
+ $name = $node->getName();
+ $size = $node->getSize();
+
$fullPath = $node->getPath();
$pathSegments = explode('/', $fullPath, 4);
- $path = $pathSegments[3] ?? $path;
+ $path = $pathSegments[3] ?? $name;
}
$url = $this->url->linkToRouteAbsolute('files.viewcontroller.showFile', [
'fileid' => $node->getId(),
]);
} else {
+ $node = $share->getNode();
+ $name = $node->getName();
+ $size = $node->getSize();
+ $path = $name;
+
$url = $this->url->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', [
'token' => $share->getToken(),
]);