Skip to content

Commit

Permalink
Make sure that the transfer entry is present in the database
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Feb 24, 2020
1 parent 982df16 commit 1e8048a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions apps/files/lib/Controller/TransferOwnershipController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
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;
Expand Down Expand Up @@ -95,7 +96,7 @@ public function transfer(string $recipient, string $path): DataResponse {
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());
Expand Down Expand Up @@ -132,15 +133,22 @@ public function accept(int $id): DataResponse {
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);
}

Expand Down

0 comments on commit 1e8048a

Please sign in to comment.