diff --git a/apps/files_versions/lib/Listener/MetadataFileEvents.php b/apps/files_versions/lib/Listener/MetadataFileEvents.php index b58b6b4394a35..fea546e5988d2 100644 --- a/apps/files_versions/lib/Listener/MetadataFileEvents.php +++ b/apps/files_versions/lib/Listener/MetadataFileEvents.php @@ -60,7 +60,7 @@ public function post_write_hook(Node $node): void { } // check if our version manager supports setting the metadata if ($this->versionManager instanceof IMetadataVersionBackend) { - $author = $this->userSession->getUser()->getDisplayName() ?? ''; + $author = $this->userSession->getUser()->getUID(); $this->versionManager->setMetadataValue($node, "author", $author); } } diff --git a/apps/files_versions/lib/Sabre/Plugin.php b/apps/files_versions/lib/Sabre/Plugin.php index de933ecc7d302..04065bde4cce7 100644 --- a/apps/files_versions/lib/Sabre/Plugin.php +++ b/apps/files_versions/lib/Sabre/Plugin.php @@ -44,6 +44,8 @@ class Plugin extends ServerPlugin { public const VERSION_LABEL = '{http://nextcloud.org/ns}version-label'; + public const VERSION_AUTHOR = '{http://nextcloud.org/ns}version-author'; // dav property for author + public function __construct( private IRequest $request, private IPreview $previewManager, @@ -93,6 +95,7 @@ public function afterGet(RequestInterface $request, ResponseInterface $response) public function propFind(PropFind $propFind, INode $node): void { if ($node instanceof VersionFile) { $propFind->handle(self::VERSION_LABEL, fn () => $node->getLabel()); + $propFind->handle(self::VERSION_AUTHOR, fn () => $node->getMetadataAuthor()); $propFind->handle(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, fn () => $this->previewManager->isMimeSupported($node->getContentType())); } } diff --git a/apps/files_versions/lib/Sabre/VersionFile.php b/apps/files_versions/lib/Sabre/VersionFile.php index 8fd97b0636f75..ec98d24dd0636 100644 --- a/apps/files_versions/lib/Sabre/VersionFile.php +++ b/apps/files_versions/lib/Sabre/VersionFile.php @@ -27,6 +27,7 @@ namespace OCA\Files_Versions\Sabre; use OCA\Files_Versions\Versions\IDeletableVersionBackend; +use OCA\Files_Versions\Versions\IMetadataVersion; use OCA\Files_Versions\Versions\INameableVersion; use OCA\Files_Versions\Versions\INameableVersionBackend; use OCA\Files_Versions\Versions\IVersion; @@ -109,6 +110,13 @@ public function setLabel($label): bool { } } + public function getMetadataAuthor(): string { + if ($this->version instanceof IMetadataVersion) { + return $this->version->getMetadataValue("author"); + } + return ''; + } + public function getLastModified(): int { return $this->version->getTimestamp(); } diff --git a/apps/files_versions/lib/Versions/Version.php b/apps/files_versions/lib/Versions/Version.php index 0dade222abce1..0e5417783e4d0 100644 --- a/apps/files_versions/lib/Versions/Version.php +++ b/apps/files_versions/lib/Versions/Version.php @@ -26,9 +26,10 @@ namespace OCA\Files_Versions\Versions; use OCP\Files\FileInfo; +use OCP\Files\Node; use OCP\IUser; -class Version implements IVersion, INameableVersion { +class Version implements IVersion, INameableVersion, IMetadataVersion { /** @var int */ private $timestamp; @@ -121,4 +122,11 @@ public function getVersionPath(): string { public function getUser(): IUser { return $this->user; } + + public function getMetadataValue(string $key): string { + if ($this->backend instanceof IMetadataVersionBackend && $this->sourceFileInfo instanceof Node) { + return $this->backend->getMetadataValue($this->sourceFileInfo, "author") ?? ''; + } + return ''; + } } diff --git a/apps/files_versions/src/utils/davRequest.js b/apps/files_versions/src/utils/davRequest.js index d3fe729aaabd3..93f1861006b85 100644 --- a/apps/files_versions/src/utils/davRequest.js +++ b/apps/files_versions/src/utils/davRequest.js @@ -31,6 +31,7 @@ export default ` + `