diff --git a/lib/Db/ShareWrapperRequest.php b/lib/Db/ShareWrapperRequest.php index 0edb5207d..41e6a493f 100644 --- a/lib/Db/ShareWrapperRequest.php +++ b/lib/Db/ShareWrapperRequest.php @@ -40,7 +40,8 @@ class ShareWrapperRequest extends ShareWrapperRequestBuilder { */ public function save(IShare $share, int $parentId = 0): int { $qb = $this->getShareInsertSql(); - $qb->setValue('share_type', $qb->createNamedParameter($share->getShareType())) + $qb->setValue('attributes', $qb->createNamedParameter($this->formatShareAttributes($share->getAttributes()))) + ->setValue('share_type', $qb->createNamedParameter($share->getShareType())) ->setValue('item_type', $qb->createNamedParameter($share->getNodeType())) ->setValue('item_source', $qb->createNamedParameter($share->getNodeId())) ->setValue('file_source', $qb->createNamedParameter($share->getNodeId())) @@ -514,7 +515,7 @@ private function formatShareAttributes(?IAttributes $attributes): ?string { $compressedAttributes[] = [ $attribute['scope'], $attribute['key'], - $attribute['enabled'] + $attribute['value'] ]; } diff --git a/lib/Model/ShareWrapper.php b/lib/Model/ShareWrapper.php index c3d605b57..cf73ea08d 100644 --- a/lib/Model/ShareWrapper.php +++ b/lib/Model/ShareWrapper.php @@ -478,6 +478,8 @@ public function import(array $data): IDeserializable { ->setToken($this->get('token', $data)) ->setShareTime($shareTime); + $this->importAttributesFromDatabase($this->get('attributes', $data)); + try { $this->setExpirationDate(new DateTime($this->get('expiration', $data))); } catch (\Exception $e) { @@ -590,7 +592,7 @@ public function jsonSerialize(): array { 'shareType' => $this->getShareType(), 'providerId' => $this->getProviderId(), 'permissions' => $this->getPermissions(), - 'attributes' => $this->getAttributes(), + 'attributes' => json_encode($this->getAttributes()->toArray()), 'hideDownload' => $this->getHideDownload(), 'itemType' => $this->getItemType(), 'itemSource' => $this->getItemSource(),