Skip to content

Commit 0d0a7ba

Browse files
authored
Merge pull request #1731 from nextcloud/fix/part-of/46920/save-share-attributes-on-create
fix(ShareWrapperRequest): Save share attributes on creation
2 parents 0635797 + b0a6f3b commit 0d0a7ba

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/Db/ShareWrapperRequest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class ShareWrapperRequest extends ShareWrapperRequestBuilder {
4040
*/
4141
public function save(IShare $share, int $parentId = 0): int {
4242
$qb = $this->getShareInsertSql();
43-
$qb->setValue('share_type', $qb->createNamedParameter($share->getShareType()))
43+
$qb->setValue('attributes', $qb->createNamedParameter($this->formatShareAttributes($share->getAttributes())))
44+
->setValue('share_type', $qb->createNamedParameter($share->getShareType()))
4445
->setValue('item_type', $qb->createNamedParameter($share->getNodeType()))
4546
->setValue('item_source', $qb->createNamedParameter($share->getNodeId()))
4647
->setValue('file_source', $qb->createNamedParameter($share->getNodeId()))
@@ -514,7 +515,7 @@ private function formatShareAttributes(?IAttributes $attributes): ?string {
514515
$compressedAttributes[] = [
515516
$attribute['scope'],
516517
$attribute['key'],
517-
$attribute['enabled']
518+
$attribute['value']
518519
];
519520
}
520521

lib/Model/ShareWrapper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ public function import(array $data): IDeserializable {
478478
->setToken($this->get('token', $data))
479479
->setShareTime($shareTime);
480480

481+
$this->importAttributesFromDatabase($this->get('attributes', $data));
482+
481483
try {
482484
$this->setExpirationDate(new DateTime($this->get('expiration', $data)));
483485
} catch (\Exception $e) {
@@ -590,7 +592,7 @@ public function jsonSerialize(): array {
590592
'shareType' => $this->getShareType(),
591593
'providerId' => $this->getProviderId(),
592594
'permissions' => $this->getPermissions(),
593-
'attributes' => $this->getAttributes(),
595+
'attributes' => json_encode($this->getAttributes()->toArray()),
594596
'hideDownload' => $this->getHideDownload(),
595597
'itemType' => $this->getItemType(),
596598
'itemSource' => $this->getItemSource(),

0 commit comments

Comments
 (0)