Skip to content
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
fix(sharing): Handle share notes
This will first properly save the note in the DB,
and then properly retrieve it.

Signed-off-by: Louis Chemineau <[email protected]>
  • Loading branch information
artonge committed Apr 8, 2025
commit 1d4830eb28bb931528597c40fed6781baf7208f9
1 change: 1 addition & 0 deletions lib/Db/CoreRequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class CoreRequestBuilder {
'file_target',
'permissions',
'attributes',
'note',
'stime',
'accepted',
'expiration',
Expand Down
1 change: 1 addition & 0 deletions lib/Db/ShareWrapperRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,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('note', $qb->createNamedParameter($shareWrapper->getShareNote()))
->set('expiration', $qb->createNamedParameter($shareWrapper->getExpirationDate(), IQueryBuilder::PARAM_DATE))
->set('attributes', $qb->createNamedParameter($shareAttributes));

Expand Down
19 changes: 17 additions & 2 deletions lib/Model/ShareWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ShareWrapper extends ManagedModel implements IDeserializable, IQueryRow, J
private int $status = 0;
private string $providerId = '';
private DateTime $shareTime;
private string $note = '';
private string $sharedWith = '';
private string $sharedBy = '';
private ?DateTime $expirationDate = null;
Expand Down Expand Up @@ -183,6 +184,16 @@ public function getShareTime(): DateTime {
return $this->shareTime;
}

public function setShareNote(string $note): self {
$this->note = $note;

return $this;
}

public function getShareNote(): string {
return $this->note;
}

public function setSharedWith(string $sharedWith): self {
$this->sharedWith = $sharedWith;

Expand Down Expand Up @@ -383,6 +394,7 @@ public function getShare(
$share->setToken($this->getToken());
$share->setHideDownload($this->getHideDownload());
$share->setAttributes($this->getAttributes());
$share->setNote($this->getShareNote());
if ($this->hasShareToken()) {
$password = $this->getShareToken()->getPassword();
if ($password !== '') {
Expand Down Expand Up @@ -477,7 +489,8 @@ public function import(array $data): IDeserializable {
->setSharedBy($this->get('sharedBy', $data))
->setShareOwner($this->get('shareOwner', $data))
->setToken($this->get('token', $data))
->setShareTime($shareTime);
->setShareTime($shareTime)
->setShareNote($this->get('note', $data));

$this->importAttributesFromDatabase($this->get('attributes', $data));

Expand Down Expand Up @@ -541,7 +554,8 @@ public function importFromDatabase(array $data, string $prefix = ''): IQueryRow
->setSharedBy($this->get($prefix . 'uid_initiator', $data))
->setShareOwner($this->get($prefix . 'uid_owner', $data))
->setToken($this->get($prefix . 'token', $data))
->setShareTime($shareTime);
->setShareTime($shareTime)
->setShareNote($this->get($prefix . 'note', $data));

$this->importAttributesFromDatabase($this->get('attributes', $data));

Expand Down Expand Up @@ -602,6 +616,7 @@ public function jsonSerialize(): array {
'fileTarget' => $this->getFileTarget(),
'status' => $this->getStatus(),
'shareTime' => $this->getShareTime()->getTimestamp(),
'note' => $this->getShareNote(),
'sharedWith' => $this->getSharedWith(),
'sharedBy' => $this->getSharedBy(),
'shareOwner' => $this->getShareOwner(),
Expand Down
3 changes: 2 additions & 1 deletion lib/ShareByCircleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ public function update(IShare $share): IShare {
->setShareOwner($share->getShareOwner())
->setAttributes($share->getAttributes())
->setSharedBy($share->getSharedBy())
->setExpirationDate($share->getExpirationDate());
->setExpirationDate($share->getExpirationDate())
->setShareNote($share->getNote());

$this->shareWrapperService->update($wrappedShare);

Expand Down
Loading