diff --git a/lib/Db/ShareWrapperRequest.php b/lib/Db/ShareWrapperRequest.php index 18286ad5f..8f84f3b55 100644 --- a/lib/Db/ShareWrapperRequest.php +++ b/lib/Db/ShareWrapperRequest.php @@ -38,6 +38,7 @@ use OCA\Circles\Model\Membership; use OCA\Circles\Model\Probes\CircleProbe; use OCA\Circles\Model\ShareWrapper; +use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Folder; use OCP\Files\NotFoundException; use OCP\Share\Exceptions\IllegalIDChangeException; @@ -71,6 +72,7 @@ public function save(IShare $share, int $parentId = 0): int { ->setValue('share_with', $qb->createNamedParameter($share->getSharedWith())) ->setValue('uid_owner', $qb->createNamedParameter($share->getShareOwner())) ->setValue('uid_initiator', $qb->createNamedParameter($share->getSharedBy())) + ->setValue('expiration', $qb->createNamedParameter($share->getExpirationDate(), IQueryBuilder::PARAM_DATE)) ->setValue('accepted', $qb->createNamedParameter(IShare::STATUS_ACCEPTED)) ->setValue('password', $qb->createNamedParameter($password)) ->setValue('permissions', $qb->createNamedParameter($share->getPermissions())) @@ -105,6 +107,7 @@ public function update(ShareWrapper $shareWrapper): void { ->set('uid_initiator', $qb->createNamedParameter($shareWrapper->getSharedBy())) ->set('accepted', $qb->createNamedParameter(IShare::STATUS_ACCEPTED)) ->set('permissions', $qb->createNamedParameter($shareWrapper->getPermissions())) + ->set('expiration', $qb->createNamedParameter($shareWrapper->getExpirationDate(), IQueryBuilder::PARAM_DATE)) ->set('attributes', $qb->createNamedParameter($shareAttributes)); $qb->limitToId((int)$shareWrapper->getId()); diff --git a/lib/Model/ShareWrapper.php b/lib/Model/ShareWrapper.php index 4909582bc..78b66d9e5 100644 --- a/lib/Model/ShareWrapper.php +++ b/lib/Model/ShareWrapper.php @@ -74,6 +74,7 @@ class ShareWrapper extends ManagedModel implements IDeserializable, IQueryRow, J private DateTime $shareTime; private string $sharedWith = ''; private string $sharedBy = ''; + private ?DateTime $expirationDate = null; private string $shareOwner = ''; private int $shareType = 0; private ?Circle $circle = null; @@ -217,6 +218,16 @@ public function setSharedBy(string $sharedBy): self { return $this; } + public function getExpirationDate(): ?DateTime { + return $this->expirationDate; + } + + public function setExpirationDate(?DateTime $date):self { + $this->expirationDate = $date; + + return $this; + } + public function getSharedBy(): string { return $this->sharedBy; } @@ -494,6 +505,11 @@ public function import(array $data): IDeserializable { ->setToken($this->get('token', $data)) ->setShareTime($shareTime); + try { + $this->setExpirationDate(new DateTime($this->get('expiration', $data))); + } catch (\Exception $e) { + } + $this->setChildId($this->getInt('childId', $data)) ->setChildFileTarget($this->get('childFileTarget', $data)) ->setChildPermissions($this->getInt('childPermissions', $data)) diff --git a/lib/ShareByCircleProvider.php b/lib/ShareByCircleProvider.php index 31c379b3d..5a837a2a7 100644 --- a/lib/ShareByCircleProvider.php +++ b/lib/ShareByCircleProvider.php @@ -227,7 +227,8 @@ public function update(IShare $share): IShare { $wrappedShare->setPermissions($share->getPermissions()) ->setShareOwner($share->getShareOwner()) ->setAttributes($share->getAttributes()) - ->setSharedBy($share->getSharedBy()); + ->setSharedBy($share->getSharedBy()) + ->setExpirationDate($share->getExpirationDate()); $this->shareWrapperService->update($wrappedShare);