Skip to content

Commit

Permalink
store expiration date
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Dec 19, 2023
1 parent d07205a commit 42dbc49
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/Db/ShareWrapperRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()))
Expand Down Expand Up @@ -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());
Expand Down
16 changes: 16 additions & 0 deletions lib/Model/ShareWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion lib/ShareByCircleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 42dbc49

Please sign in to comment.