Browse Source

Merge pull request #48597 from nextcloud/fix/fix-email-share-transfer-accross-storages

Fix email share transfer accross storages
pull/48619/head
Côme Chilliet 1 year ago
committed by GitHub
parent
commit
05886d281d
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      apps/files/lib/Service/OwnershipTransferService.php
  2. 5
      apps/sharebymail/lib/ShareByMailProvider.php
  3. 2
      apps/sharebymail/tests/ShareByMailProviderTest.php

2
apps/files/lib/Service/OwnershipTransferService.php

@ -420,6 +420,7 @@ class OwnershipTransferService {
foreach ($shares as ['share' => $share, 'suffix' => $suffix]) {
try {
$output->writeln('Transfering share ' . $share->getId() . ' of type ' . $share->getShareType(), OutputInterface::VERBOSITY_VERBOSE);
if ($share->getShareType() === IShare::TYPE_USER &&
$share->getSharedWith() === $destinationUid) {
// Unmount the shares before deleting, so we don't try to get the storage later on.
@ -457,6 +458,7 @@ class OwnershipTransferService {
// Try to get the new ID from the target path and suffix of the share
$node = $rootFolder->get(Filesystem::normalizePath($targetLocation . '/' . $suffix));
$newNodeId = $node->getId();
$output->writeln('Had to change node id to ' . $newNodeId, OutputInterface::VERBOSITY_VERY_VERBOSE);
}
$share->setNodeId($newNodeId);

5
apps/sharebymail/lib/ShareByMailProvider.php

@ -739,11 +739,14 @@ class ShareByMailProvider extends DefaultShareProvider implements IShareProvider
$shareAttributes = $this->formatShareAttributes($share->getAttributes());
/*
* We allow updating the permissions and password of mail shares
* We allow updating mail shares
*/
$qb = $this->dbConnection->getQueryBuilder();
$qb->update('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())))
->set('item_source', $qb->createNamedParameter($share->getNodeId()))
->set('file_source', $qb->createNamedParameter($share->getNodeId()))
->set('share_with', $qb->createNamedParameter($share->getSharedWith()))
->set('permissions', $qb->createNamedParameter($share->getPermissions()))
->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()))
->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()))

2
apps/sharebymail/tests/ShareByMailProviderTest.php

@ -755,6 +755,8 @@ class ShareByMailProviderTest extends TestCase {
$this->share->expects($this->once())->method('getSharedBy')->willReturn($sharedBy);
$this->share->expects($this->any())->method('getNote')->willReturn($note);
$this->share->expects($this->atLeastOnce())->method('getId')->willReturn($id);
$this->share->expects($this->atLeastOnce())->method('getNodeId')->willReturn($itemSource);
$this->share->expects($this->once())->method('getSharedWith')->willReturn($shareWith);
$this->assertSame($this->share,
$instance->update($this->share)

Loading…
Cancel
Save