Skip to content

Commit

Permalink
fix(files_version): deprecated INameableVersion
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Morales <emoral435@gmail.com>
  • Loading branch information
emoral435 committed Mar 11, 2024
1 parent 4cf4fdc commit a8844d4
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 13 deletions.
3 changes: 2 additions & 1 deletion apps/files_versions/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,14 @@ public function register(IRegistrationContext $context): void {
$context->registerEventListener(NodeTouchedEvent::class, FileEventsListener::class);
$context->registerEventListener(BeforeNodeWrittenEvent::class, FileEventsListener::class);
$context->registerEventListener(NodeWrittenEvent::class, FileEventsListener::class);
$context->registerEventListener(NodeWrittenEvent::class, MetadataFileEvents::class);
$context->registerEventListener(BeforeNodeDeletedEvent::class, FileEventsListener::class);
$context->registerEventListener(NodeDeletedEvent::class, FileEventsListener::class);
$context->registerEventListener(NodeRenamedEvent::class, FileEventsListener::class);
$context->registerEventListener(NodeCopiedEvent::class, FileEventsListener::class);
$context->registerEventListener(BeforeNodeRenamedEvent::class, FileEventsListener::class);
$context->registerEventListener(BeforeNodeCopiedEvent::class, FileEventsListener::class);

$context->registerEventListener(NodeWrittenEvent::class, MetadataFileEvents::class);
}

public function boot(IBootContext $context): void {
Expand Down
4 changes: 2 additions & 2 deletions apps/files_versions/lib/Db/VersionEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public function setLabel(string $label): void {
* if nothing is found, we return an empty string
* @param string $key key associated with the value
*/
public function getMetadataValue(string $key): string {
return $this->metadata[$key] ?? '';
public function getMetadataValue(string $key): ?string {
return $this->metadata[$key] ?? null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion apps/files_versions/lib/Sabre/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +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(self::VERSION_AUTHOR, fn () => $node->getMetadataValue("author"));
$propFind->handle(FilesPlugin::HAS_PREVIEW_PROPERTYNAME, fn () => $this->previewManager->isMimeSupported($node->getContentType()));
}
}
Expand Down
6 changes: 3 additions & 3 deletions apps/files_versions/lib/Sabre/VersionFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ public function setLabel($label): bool {
}
}

public function getMetadataAuthor(): string {
public function getMetadataValue(string $key): ?string {
if ($this->version instanceof IMetadataVersion) {
return $this->version->getMetadataValue("author");
return $this->version->getMetadataValue($key);
}
return '';
return null;
}

public function getLastModified(): int {
Expand Down
2 changes: 1 addition & 1 deletion apps/files_versions/lib/Versions/IMetadataVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ interface IMetadataVersion {
* @param string $key the key for the json value of the metadata column
* @since 29.0.0
*/
public function getMetadataValue(string $key): string;
public function getMetadataValue(string $key): ?string;
}
3 changes: 2 additions & 1 deletion apps/files_versions/lib/Versions/INameableVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
namespace OCA\Files_Versions\Versions;

/**
* @deprecated 29.0.0
* @since 26.0.0
*/
interface INameableVersion {
/**
* Get the user created label
*
* @deprecated 29.0.0
* @return string
* @since 26.0.0
*/
Expand Down
3 changes: 2 additions & 1 deletion apps/files_versions/lib/Versions/INameableVersionBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@
namespace OCA\Files_Versions\Versions;

/**
* @deprecated 29.0.0
* @since 26.0.0
*/
interface INameableVersionBackend {
/**
* Set the label for a version.
*
* @deprecated 29.0.0
* @since 26.0.0
*/
public function setVersionLabel(IVersion $version, string $label): void;
Expand Down
6 changes: 3 additions & 3 deletions apps/files_versions/lib/Versions/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ public function getUser(): IUser {
return $this->user;
}

public function getMetadataValue(string $key): string {
public function getMetadataValue(string $key): ?string {
if ($this->backend instanceof IMetadataVersionBackend && $this->sourceFileInfo instanceof Node) {
return $this->backend->getMetadataValue($this->sourceFileInfo, "author") ?? '';
return $this->backend->getMetadataValue($this->sourceFileInfo, "author");
}
return '';
return null;
}
}

0 comments on commit a8844d4

Please sign in to comment.