|
15 | 15 | use NCU\Sharing\ISharingManager; |
16 | 16 | use NCU\Sharing\Permission\ISharePermissionType; |
17 | 17 | use NCU\Sharing\Permission\SharePermission; |
| 18 | +use NCU\Sharing\Property\ISharePropertyType; |
| 19 | +use NCU\Sharing\Property\ShareProperty; |
18 | 20 | use NCU\Sharing\Recipient\IShareRecipientType; |
19 | 21 | use NCU\Sharing\Recipient\ShareRecipient; |
20 | 22 | use NCU\Sharing\Share; |
|
25 | 27 | use OC\Core\Sharing\Property\ExpirationDateSharePropertyType; |
26 | 28 | use OC\Core\Sharing\Property\LabelSharePropertyType; |
27 | 29 | use OC\Core\Sharing\Property\NoteSharePropertyType; |
| 30 | +use OC\Core\Sharing\Property\PasswordSharePropertyType; |
28 | 31 | use OC\Core\Sharing\Recipient\EmailShareRecipientType; |
29 | 32 | use OC\Core\Sharing\Recipient\GroupShareRecipientType; |
30 | 33 | use OC\Core\Sharing\Recipient\TeamShareRecipientType; |
@@ -361,8 +364,19 @@ public function getShare(string $id): Share { |
361 | 364 | null, |
362 | 365 | ); |
363 | 366 |
|
364 | | - // TODO |
365 | | - $properties = []; |
| 367 | + if (!$this->checkAllSame($legacyShares, fn (IShare $share) => $share->getExpirationDate())) { |
| 368 | + throw new \Exception('All legacy shares sharing a share id don\'t have the expiration date'); |
| 369 | + } |
| 370 | + if (!$this->checkAllSame($legacyShares, fn (IShare $share) => $share->getPassword())) { |
| 371 | + throw new \Exception('All legacy shares sharing a share id don\'t have the password'); |
| 372 | + } |
| 373 | + if (!$this->checkAllSame($legacyShares, fn (IShare $share) => $share->getLabel())) { |
| 374 | + throw new \Exception('All legacy shares sharing a share id don\'t have the label'); |
| 375 | + } |
| 376 | + if (!$this->checkAllSame($legacyShares, fn (IShare $share) => $share->getNote())) { |
| 377 | + throw new \Exception('All legacy shares sharing a share id don\'t have the note'); |
| 378 | + } |
| 379 | + $properties = $this->extractProperties($legacyShares[0]); |
366 | 380 |
|
367 | 381 | if (!$this->checkAllSame($legacyShares, fn (IShare $share) => $share->getAttributes())) { |
368 | 382 | throw new \Exception('All legacy shares sharing a share id don\'t have the same attributes'); |
@@ -392,7 +406,7 @@ public function getShare(string $id): Share { |
392 | 406 | $id, |
393 | 407 | $owner, |
394 | 408 | // TODO |
395 | | - 0, |
| 409 | + \DateTimeImmutable::createFromMutable($legacyShares[0]->getShareTime()), |
396 | 410 | // TODO |
397 | 411 | ShareState::Active, |
398 | 412 | array_values($sources), |
@@ -603,4 +617,27 @@ private function splitLegacySharedWith(int $shareType, string $sharedWith): arra |
603 | 617 | ]; |
604 | 618 | } |
605 | 619 | } |
| 620 | + |
| 621 | + /** |
| 622 | + * @param IShare $share |
| 623 | + * @return ShareProperty[] |
| 624 | + */ |
| 625 | + private function extractProperties(IShare $share): array { |
| 626 | + $properties = []; |
| 627 | + |
| 628 | + if ($expire = $share->getExpirationDate()) { |
| 629 | + $properties[] = new ShareProperty(ExpirationDateSharePropertyType::class, $expire->format(DateTimeInterface::ATOM)); |
| 630 | + } |
| 631 | + if ($password = $share->getPassword()) { |
| 632 | + $properties[] = new ShareProperty(PasswordSharePropertyType::class, $password); |
| 633 | + } |
| 634 | + if ($label = $share->getLabel()) { |
| 635 | + $properties[] = new ShareProperty(LabelSharePropertyType::class, $label); |
| 636 | + } |
| 637 | + if ($note = $share->getNote()) { |
| 638 | + $properties[] = new ShareProperty(NoteSharePropertyType::class, $note); |
| 639 | + } |
| 640 | + |
| 641 | + return $properties; |
| 642 | + } |
606 | 643 | } |
0 commit comments