Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable28] store expiration date #1459

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading