Skip to content

Commit 484421b

Browse files
authored
Merge pull request #1962 from nextcloud/artonge/fix/handle_share_notes
fix(sharing): Handle share notes
2 parents fab7d07 + 1d4830e commit 484421b

4 files changed

Lines changed: 21 additions & 3 deletions

File tree

lib/Db/CoreRequestBuilder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class CoreRequestBuilder {
151151
'file_target',
152152
'permissions',
153153
'attributes',
154+
'note',
154155
'stime',
155156
'accepted',
156157
'expiration',

lib/Db/ShareWrapperRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public function update(ShareWrapper $shareWrapper): void {
8484
->set('uid_initiator', $qb->createNamedParameter($shareWrapper->getSharedBy()))
8585
->set('accepted', $qb->createNamedParameter(IShare::STATUS_ACCEPTED))
8686
->set('permissions', $qb->createNamedParameter($shareWrapper->getPermissions()))
87+
->set('note', $qb->createNamedParameter($shareWrapper->getShareNote()))
8788
->set('expiration', $qb->createNamedParameter($shareWrapper->getExpirationDate(), IQueryBuilder::PARAM_DATE))
8889
->set('attributes', $qb->createNamedParameter($shareAttributes));
8990

lib/Model/ShareWrapper.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class ShareWrapper extends ManagedModel implements IDeserializable, IQueryRow, J
5252
private int $status = 0;
5353
private string $providerId = '';
5454
private DateTime $shareTime;
55+
private string $note = '';
5556
private string $sharedWith = '';
5657
private string $sharedBy = '';
5758
private ?DateTime $expirationDate = null;
@@ -183,6 +184,16 @@ public function getShareTime(): DateTime {
183184
return $this->shareTime;
184185
}
185186

187+
public function setShareNote(string $note): self {
188+
$this->note = $note;
189+
190+
return $this;
191+
}
192+
193+
public function getShareNote(): string {
194+
return $this->note;
195+
}
196+
186197
public function setSharedWith(string $sharedWith): self {
187198
$this->sharedWith = $sharedWith;
188199

@@ -383,6 +394,7 @@ public function getShare(
383394
$share->setToken($this->getToken());
384395
$share->setHideDownload($this->getHideDownload());
385396
$share->setAttributes($this->getAttributes());
397+
$share->setNote($this->getShareNote());
386398
if ($this->hasShareToken()) {
387399
$password = $this->getShareToken()->getPassword();
388400
if ($password !== '') {
@@ -477,7 +489,8 @@ public function import(array $data): IDeserializable {
477489
->setSharedBy($this->get('sharedBy', $data))
478490
->setShareOwner($this->get('shareOwner', $data))
479491
->setToken($this->get('token', $data))
480-
->setShareTime($shareTime);
492+
->setShareTime($shareTime)
493+
->setShareNote($this->get('note', $data));
481494

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

@@ -541,7 +554,8 @@ public function importFromDatabase(array $data, string $prefix = ''): IQueryRow
541554
->setSharedBy($this->get($prefix . 'uid_initiator', $data))
542555
->setShareOwner($this->get($prefix . 'uid_owner', $data))
543556
->setToken($this->get($prefix . 'token', $data))
544-
->setShareTime($shareTime);
557+
->setShareTime($shareTime)
558+
->setShareNote($this->get($prefix . 'note', $data));
545559

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

@@ -602,6 +616,7 @@ public function jsonSerialize(): array {
602616
'fileTarget' => $this->getFileTarget(),
603617
'status' => $this->getStatus(),
604618
'shareTime' => $this->getShareTime()->getTimestamp(),
619+
'note' => $this->getShareNote(),
605620
'sharedWith' => $this->getSharedWith(),
606621
'sharedBy' => $this->getSharedBy(),
607622
'shareOwner' => $this->getShareOwner(),

lib/ShareByCircleProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ public function update(IShare $share): IShare {
208208
->setShareOwner($share->getShareOwner())
209209
->setAttributes($share->getAttributes())
210210
->setSharedBy($share->getSharedBy())
211-
->setExpirationDate($share->getExpirationDate());
211+
->setExpirationDate($share->getExpirationDate())
212+
->setShareNote($share->getNote());
212213

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

0 commit comments

Comments
 (0)