diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2024-10-17 08:39:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-17 08:39:21 +0200 |
commit | 681ee75ab99b490acc6dc98ec99f27778de7f057 (patch) | |
tree | dcba9301126d00c83ea4a230082ef5417e55dc80 /apps/files/lib | |
parent | de9f5c4ec6b441100cd3f79f246daf452049fe95 (diff) | |
parent | 73b34bba7b70d3296ce8eba633a4d9c61cf01904 (diff) | |
download | nextcloud-server-681ee75ab99b490acc6dc98ec99f27778de7f057.tar.gz nextcloud-server-681ee75ab99b490acc6dc98ec99f27778de7f057.zip |
Merge pull request #48734 from nextcloud/fix/45884/accept-notification
fix: get rid of denied notification when accept
Diffstat (limited to 'apps/files/lib')
-rw-r--r-- | apps/files/lib/Controller/TransferOwnershipController.php | 15 | ||||
-rw-r--r-- | apps/files/lib/Notification/Notifier.php | 19 |
2 files changed, 23 insertions, 11 deletions
diff --git a/apps/files/lib/Controller/TransferOwnershipController.php b/apps/files/lib/Controller/TransferOwnershipController.php index a71373baae4..4ef6e392039 100644 --- a/apps/files/lib/Controller/TransferOwnershipController.php +++ b/apps/files/lib/Controller/TransferOwnershipController.php @@ -140,22 +140,15 @@ 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); } diff --git a/apps/files/lib/Notification/Notifier.php b/apps/files/lib/Notification/Notifier.php index bae3a513df7..89ddbb9b6ec 100644 --- a/apps/files/lib/Notification/Notifier.php +++ b/apps/files/lib/Notification/Notifier.php @@ -8,9 +8,11 @@ declare(strict_types=1); */ namespace OCA\Files\Notification; +use OCA\Files\BackgroundJob\TransferOwnership; use OCA\Files\Db\TransferOwnershipMapper; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; +use OCP\BackgroundJob\IJobList; use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; @@ -36,15 +38,19 @@ class Notifier implements INotifier, IDismissableNotifier { private $userManager; /** @var ITimeFactory */ private $timeFactory; + /** @var IJobList */ + private $jobList; public function __construct(IFactory $l10nFactory, IURLGenerator $urlGenerator, TransferOwnershipMapper $mapper, IManager $notificationManager, IUserManager $userManager, + IJobList $jobList, ITimeFactory $timeFactory) { $this->l10nFactory = $l10nFactory; $this->urlGenerator = $urlGenerator; + $this->jobList = $jobList; $this->mapper = $mapper; $this->notificationManager = $notificationManager; $this->userManager = $userManager; @@ -70,6 +76,10 @@ class Notifier implements INotifier, IDismissableNotifier { throw new UnknownNotificationException('Unhandled app'); } + $imagePath = $this->urlGenerator->imagePath('files', 'folder-move.svg'); + $iconUrl = $this->urlGenerator->getAbsoluteURL($imagePath); + $notification->setIcon($iconUrl); + return match($notification->getSubject()) { 'transferownershipRequest' => $this->handleTransferownershipRequest($notification, $languageCode), 'transferownershipRequestDenied' => $this->handleTransferOwnershipRequestDenied($notification, $languageCode), @@ -259,6 +269,9 @@ class Notifier implements INotifier, IDismissableNotifier { if ($notification->getApp() !== 'files') { throw new UnknownNotificationException('Unhandled app'); } + if ($notification->getSubject() !== 'transferownershipRequest') { + throw new UnknownNotificationException('Unhandled notification type'); + } // TODO: This should all be moved to a service that also the transferownershipController uses. try { @@ -267,6 +280,12 @@ class Notifier implements INotifier, IDismissableNotifier { return; } + if ($this->jobList->has(TransferOwnership::class, [ + 'id' => $transferOwnership->getId(), + ])) { + return; + } + $notification = $this->notificationManager->createNotification(); $notification->setUser($transferOwnership->getSourceUser()) ->setApp('files') |