Skip to content

Commit

Permalink
perf(sharing): Use getFirstNodeById() which is more performant
Browse files Browse the repository at this point in the history
As we don't care which node we get for rendering the message

Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jun 20, 2024
1 parent 64cc79b commit 5e48b86
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -757,23 +757,23 @@ protected function getFileFromShare(Room $room, ?Participant $participant, strin
if ($share->getShareOwner() !== $participant->getAttendee()->getActorId()) {
$userFolder = $this->rootFolder->getUserFolder($participant->getAttendee()->getActorId());
if ($userFolder instanceof Node) {
$userNodes = $userFolder->getById($share->getNodeId());

if (empty($userNodes)) {
$node = $userFolder->getFirstNodeById($share->getNodeId());
if (!$node instanceof Node) {
// 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($share->getNodeId());
}

if (empty($userNodes)) {
throw new NotFoundException('File was not found');
if (empty($userNodes)) {
throw new NotFoundException('File was not found');
}

/** @var Node $node */
$node = reset($userNodes);
}

/** @var Node $node */
$node = reset($userNodes);
$fullPath = $node->getPath();
$pathSegments = explode('/', $fullPath, 4);
$name = $node->getName();
Expand Down

0 comments on commit 5e48b86

Please sign in to comment.