diff options
author | Maksim Sukharev <antreesy.web@gmail.com> | 2024-10-17 13:35:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-17 13:35:21 +0200 |
commit | 93e4d2dabfbb885a8bc67469fae2da5c74bf0590 (patch) | |
tree | df4e19745fa46332292532eabd43a47364831417 | |
parent | 3bdef7e9a2becf88b3a074a2b16b84bcaed3f33d (diff) | |
parent | 90573be1e074bedb531207114886eb83edd0e332 (diff) | |
download | nextcloud-server-93e4d2dabfbb885a8bc67469fae2da5c74bf0590.tar.gz nextcloud-server-93e4d2dabfbb885a8bc67469fae2da5c74bf0590.zip |
Merge pull request #48752 from nextcloud/backport/48734/stable29
-rw-r--r-- | apps/files/img/folder-move.svg | 1 | ||||
-rw-r--r-- | apps/files/lib/Controller/TransferOwnershipController.php | 15 | ||||
-rw-r--r-- | apps/files/lib/Notification/Notifier.php | 19 |
3 files changed, 24 insertions, 11 deletions
diff --git a/apps/files/img/folder-move.svg b/apps/files/img/folder-move.svg new file mode 100644 index 00000000000..349106f4cd9 --- /dev/null +++ b/apps/files/img/folder-move.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" id="mdi-folder-move" viewBox="0 0 24 24"><path d="M14,18V15H10V11H14V8L19,13M20,6H12L10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6Z" /></svg>
\ No newline at end of file diff --git a/apps/files/lib/Controller/TransferOwnershipController.php b/apps/files/lib/Controller/TransferOwnershipController.php index eec654bd678..d3256b2c7cc 100644 --- a/apps/files/lib/Controller/TransferOwnershipController.php +++ b/apps/files/lib/Controller/TransferOwnershipController.php @@ -160,22 +160,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 10954ac9c64..d73ab2d69b0 100644 --- a/apps/files/lib/Notification/Notifier.php +++ b/apps/files/lib/Notification/Notifier.php @@ -27,9 +27,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; @@ -54,15 +56,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; @@ -88,6 +94,10 @@ class Notifier implements INotifier, IDismissableNotifier { throw new \InvalidArgumentException('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), @@ -277,6 +287,9 @@ class Notifier implements INotifier, IDismissableNotifier { if ($notification->getApp() !== 'files') { throw new \InvalidArgumentException('Unhandled app'); } + if ($notification->getSubject() !== 'transferownershipRequest') { + throw new \InvalidArgumentException('Unhandled notification type'); + } // TODO: This should all be moved to a service that also the transferownershipController uses. try { @@ -285,6 +298,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') |