Skip to content

Commit

Permalink
Merge pull request 'fix: unknown author in version history + correct …
Browse files Browse the repository at this point in the history
…ids' from hotfix/first-version-author into develop

Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/onlyoffice-nextcloud/pulls/34
  • Loading branch information
LinneyS committed Feb 5, 2025
2 parents 8a56ac3 + 0e96e19 commit 3ec8855
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions lib/Controller/EditorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -955,10 +955,19 @@ public function history($fileId) {
"name" => $author["name"],
];
} else {
$authorName = !empty($this->config->getUnknownAuthor()) ? $this->config->getUnknownAuthor() : $owner->getDisplayName();
$historyItem["user"] = [
"name" => $authorName,
];
if (!empty($this->config->getUnknownAuthor()) && $versionNum !== 1) {
$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);
Expand All @@ -984,15 +993,17 @@ public function history($fileId) {
$versionId = $file->getFileInfo()->getMtime();

$author = FileVersions::getAuthor($ownerId, $file->getFileInfo(), $versionId);
if ($author !== null) {
if (!empty($this->config->getUnknownAuthor()) && $versionNum !== 1) {
$authorName = $this->config->getUnknownAuthor();
$historyItem["user"] = [
"id" => $this->buildUserId($author["id"]),
"name" => $author["name"]
"name" => $authorName,
];
} elseif ($owner !== null) {
} else {
$authorName = $owner->getDisplayName();
$authorId = $owner->getUID();
$historyItem["user"] = [
"id" => $this->buildUserId($ownerId),
"name" => $owner->getDisplayName()
"id" => $this->buildUserId($authorId),
"name" => $authorName,
];
}

Expand Down

0 comments on commit 3ec8855

Please sign in to comment.