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

Delay getting the node until we know that we use the data #7762

Merged
Changes from 1 commit
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
31 changes: 18 additions & 13 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,48 +570,53 @@ public function parseDeletedMessage(Message $chatMessage): void {
*/
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.
// 1. Only be executed on "Waiting for new messages"
// 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(),
]);
Expand Down