Merge pull request #19621 from nextcloud/bugfix/noid/transfer-owner-delete-notification

Make sure that the transfer details are present in the database during the cron run
This commit is contained in:
Roeland Jago Douma 2020-02-24 20:38:55 +01:00 committed by GitHub
commit 8108e6f577
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 5 deletions

View File

@ -27,6 +27,7 @@ declare(strict_types=1);
namespace OCA\Files\Controller; namespace OCA\Files\Controller;
use OCA\Files\BackgroundJob\TransferOwnership; use OCA\Files\BackgroundJob\TransferOwnership;
use OCA\Files\Db\TransferOwnership as TransferOwnershipEntity;
use OCA\Files\Db\TransferOwnershipMapper; use OCA\Files\Db\TransferOwnershipMapper;
use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
@ -95,7 +96,7 @@ class TransferOwnershipController extends OCSController {
return new DataResponse([], Http::STATUS_BAD_REQUEST); return new DataResponse([], Http::STATUS_BAD_REQUEST);
} }
$transferOwnership = new \OCA\Files\Db\TransferOwnership(); $transferOwnership = new TransferOwnershipEntity();
$transferOwnership->setSourceUser($this->userId); $transferOwnership->setSourceUser($this->userId);
$transferOwnership->setTargetUser($recipient); $transferOwnership->setTargetUser($recipient);
$transferOwnership->setFileId($node->getId()); $transferOwnership->setFileId($node->getId());
@ -132,15 +133,22 @@ class TransferOwnershipController extends OCSController {
return new DataResponse([], Http::STATUS_FORBIDDEN); return new DataResponse([], Http::STATUS_FORBIDDEN);
} }
$this->jobList->add(TransferOwnership::class, [
'id' => $transferOwnership->getId(),
]);
$notification = $this->notificationManager->createNotification(); $notification = $this->notificationManager->createNotification();
$notification->setApp('files') $notification->setApp('files')
->setObject('transfer', (string)$id); ->setObject('transfer', (string)$id);
$this->notificationManager->markProcessed($notification); $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); return new DataResponse([], Http::STATUS_OK);
} }