Skip to content

Commit

Permalink
Merge pull request #1733 from nextcloud/backport/1731/stable29
Browse files Browse the repository at this point in the history
[stable29] fix(ShareWrapperRequest): Save share attributes on creation
  • Loading branch information
nfebe authored Oct 31, 2024
2 parents 23c538a + bab79d3 commit 41a39c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/Db/ShareWrapperRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,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()))
Expand Down Expand Up @@ -534,7 +535,7 @@ private function formatShareAttributes(?IAttributes $attributes): ?string {
$compressedAttributes[] = [
$attribute['scope'],
$attribute['key'],
$attribute['enabled']
$attribute['value']
];
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Model/ShareWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,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) {
Expand Down Expand Up @@ -610,7 +612,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(),
Expand Down

0 comments on commit 41a39c4

Please sign in to comment.