Skip to content

Commit 676fb40

Browse files
committed
chore: use constants for metadata
Signed-off-by: Borja Domínguez Vázquez <[email protected]>
1 parent 26210e2 commit 676fb40

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

apps/files_versions/lib/Listener/VersionAuthorListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace OCA\Files_Versions\Listener;
1010

1111
use OC\Files\Node\Folder;
12+
use OCA\Files_Versions\Sabre\Plugin;
1213
use OCA\Files_Versions\Versions\IMetadataVersionBackend;
1314
use OCA\Files_Versions\Versions\IVersionManager;
1415
use OCP\EventDispatcher\Event;
@@ -48,7 +49,7 @@ public function post_write_hook(Node $node): void {
4849
// check if our version manager supports setting the metadata
4950
if ($this->versionManager instanceof IMetadataVersionBackend) {
5051
$author = $user->getUID();
51-
$this->versionManager->setMetadataValue($node, $node->getMTime(), 'author', $author);
52+
$this->versionManager->setMetadataValue($node, $node->getMTime(), Plugin::AUTHOR, $author);
5253
}
5354
}
5455
}

apps/files_versions/lib/Sabre/Plugin.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
class Plugin extends ServerPlugin {
2525
private Server $server;
2626

27+
public const LABEL = 'label';
28+
29+
public const AUTHOR = 'author';
30+
2731
public const VERSION_LABEL = '{http://nextcloud.org/ns}version-label';
2832

2933
public const VERSION_AUTHOR = '{http://nextcloud.org/ns}version-author'; // dav property for author
@@ -76,8 +80,8 @@ public function afterGet(RequestInterface $request, ResponseInterface $response)
7680

7781
public function propFind(PropFind $propFind, INode $node): void {
7882
if ($node instanceof VersionFile) {
79-
$propFind->handle(self::VERSION_LABEL, fn () => $node->getMetadataValue('label'));
80-
$propFind->handle(self::VERSION_AUTHOR, fn () => $node->getMetadataValue('author'));
83+
$propFind->handle(self::VERSION_LABEL, fn () => $node->getMetadataValue(self::LABEL));
84+
$propFind->handle(self::VERSION_AUTHOR, fn () => $node->getMetadataValue(self::AUTHOR));
8185
$propFind->handle(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, fn () => $this->previewManager->isMimeSupported($node->getContentType()));
8286
}
8387
}
@@ -86,7 +90,7 @@ public function propPatch($path, PropPatch $propPatch): void {
8690
$node = $this->server->tree->getNodeForPath($path);
8791

8892
if ($node instanceof VersionFile) {
89-
$propPatch->handle(self::VERSION_LABEL, fn (string $label) => $node->setMetadataValue('label', $label));
93+
$propPatch->handle(self::VERSION_LABEL, fn (string $label) => $node->setMetadataValue(self::LABEL, $label));
9094
}
9195
}
9296
}

0 commit comments

Comments
 (0)