Skip to content

Commit 8108e6f

Browse files
authored
Merge pull request nextcloud#19621 from nextcloud/bugfix/noid/transfer-owner-delete-notification
Make sure that the transfer details are present in the database during the cron run
2 parents aaf1cb7 + 1e8048a commit 8108e6f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

apps/files/lib/Controller/TransferOwnershipController.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
namespace OCA\Files\Controller;
2828

2929
use OCA\Files\BackgroundJob\TransferOwnership;
30+
use OCA\Files\Db\TransferOwnership as TransferOwnershipEntity;
3031
use OCA\Files\Db\TransferOwnershipMapper;
3132
use OCP\AppFramework\Db\DoesNotExistException;
3233
use OCP\AppFramework\Http;
@@ -95,7 +96,7 @@ public function transfer(string $recipient, string $path): DataResponse {
9596
return new DataResponse([], Http::STATUS_BAD_REQUEST);
9697
}
9798

98-
$transferOwnership = new \OCA\Files\Db\TransferOwnership();
99+
$transferOwnership = new TransferOwnershipEntity();
99100
$transferOwnership->setSourceUser($this->userId);
100101
$transferOwnership->setTargetUser($recipient);
101102
$transferOwnership->setFileId($node->getId());
@@ -132,15 +133,22 @@ public function accept(int $id): DataResponse {
132133
return new DataResponse([], Http::STATUS_FORBIDDEN);
133134
}
134135

135-
$this->jobList->add(TransferOwnership::class, [
136-
'id' => $transferOwnership->getId(),
137-
]);
138-
139136
$notification = $this->notificationManager->createNotification();
140137
$notification->setApp('files')
141138
->setObject('transfer', (string)$id);
142139
$this->notificationManager->markProcessed($notification);
143140

141+
$newTransferOwnership = new TransferOwnershipEntity();
142+
$newTransferOwnership->setNodeName($transferOwnership->getNodeName());
143+
$newTransferOwnership->setFileId($transferOwnership->getFileId());
144+
$newTransferOwnership->setSourceUser($transferOwnership->getSourceUser());
145+
$newTransferOwnership->setTargetUser($transferOwnership->getTargetUser());
146+
$this->mapper->insert($newTransferOwnership);
147+
148+
$this->jobList->add(TransferOwnership::class, [
149+
'id' => $newTransferOwnership->getId(),
150+
]);
151+
144152
return new DataResponse([], Http::STATUS_OK);
145153
}
146154

0 commit comments

Comments
 (0)