From cfa22c98cd2f3dd9a39c8434a3ee93836ed5d0b3 Mon Sep 17 00:00:00 2001 From: rivexe Date: Mon, 10 Feb 2025 17:32:44 +0300 Subject: [PATCH] fix: unknown author for last version --- lib/Controller/EditorController.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/Controller/EditorController.php b/lib/Controller/EditorController.php index 47ff1bc1..d2fdf317 100644 --- a/lib/Controller/EditorController.php +++ b/lib/Controller/EditorController.php @@ -993,18 +993,25 @@ public function history($fileId) { $versionId = $file->getFileInfo()->getMtime(); $author = FileVersions::getAuthor($ownerId, $file->getFileInfo(), $versionId); - if (!empty($this->config->getUnknownAuthor()) && $versionNum !== 1) { - $authorName = $this->config->getUnknownAuthor(); + if ($author !== null) { $historyItem["user"] = [ - "name" => $authorName, + "id" => $this->buildUserId($author["id"]), + "name" => $author["name"], ]; } else { - $authorName = $owner->getDisplayName(); - $authorId = $owner->getUID(); - $historyItem["user"] = [ - "id" => $this->buildUserId($authorId), - "name" => $authorName, - ]; + if (!empty($this->config->getUnknownAuthor()) && $versionNum !== 0) { + $authorName = $this->config->getUnknownAuthor(); + $historyItem["user"] = [ + "name" => $authorName, + ]; + } else { + $authorName = $owner->getDisplayName(); + $authorId = $owner->getUID(); + $historyItem["user"] = [ + "id" => $this->buildUserId($authorId), + "name" => $authorName, + ]; + } } $historyData = FileVersions::getHistoryData($ownerId, $file->getFileInfo(), $versionId, $prevVersion);