]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make sure that the transfer entry is present in the database 19628/head
authorJulius Härtl <jus@bitgrid.net>
Mon, 24 Feb 2020 14:01:39 +0000 (15:01 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Mon, 24 Feb 2020 19:39:55 +0000 (19:39 +0000)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
apps/files/lib/Controller/TransferOwnershipController.php

index 824c8c005181dfb39c7d71a7e326f42f8409d908..639e73187ca52b06f9f965d1c3a64d0a10bc1947 100644 (file)
@@ -27,6 +27,7 @@ declare(strict_types=1);
 namespace OCA\Files\Controller;
 
 use OCA\Files\BackgroundJob\TransferOwnership;
+use OCA\Files\Db\TransferOwnership as TransferOwnershipEntity;
 use OCA\Files\Db\TransferOwnershipMapper;
 use OCP\AppFramework\Db\DoesNotExistException;
 use OCP\AppFramework\Http;
@@ -95,7 +96,7 @@ class TransferOwnershipController extends OCSController {
                        return new DataResponse([], Http::STATUS_BAD_REQUEST);
                }
 
-               $transferOwnership = new \OCA\Files\Db\TransferOwnership();
+               $transferOwnership = new TransferOwnershipEntity();
                $transferOwnership->setSourceUser($this->userId);
                $transferOwnership->setTargetUser($recipient);
                $transferOwnership->setFileId($node->getId());
@@ -132,15 +133,22 @@ class TransferOwnershipController extends OCSController {
                        return new DataResponse([], Http::STATUS_FORBIDDEN);
                }
 
-               $this->jobList->add(TransferOwnership::class, [
-                       'id' => $transferOwnership->getId(),
-               ]);
-
                $notification = $this->notificationManager->createNotification();
                $notification->setApp('files')
                        ->setObject('transfer', (string)$id);
                $this->notificationManager->markProcessed($notification);
 
+               $newTransferOwnership = new TransferOwnershipEntity();
+               $newTransferOwnership->setNodeName($transferOwnership->getNodeName());
+               $newTransferOwnership->setFileId($transferOwnership->getFileId());
+               $newTransferOwnership->setSourceUser($transferOwnership->getSourceUser());
+               $newTransferOwnership->setTargetUser($transferOwnership->getTargetUser());
+               $this->mapper->insert($newTransferOwnership);
+
+               $this->jobList->add(TransferOwnership::class, [
+                       'id' => $newTransferOwnership->getId(),
+               ]);
+
                return new DataResponse([], Http::STATUS_OK);
        }