88 */
99namespace OCA \Files \Notification ;
1010
11+ use OCA \Files \BackgroundJob \TransferOwnership ;
1112use OCA \Files \Db \TransferOwnershipMapper ;
1213use OCP \AppFramework \Db \DoesNotExistException ;
1314use OCP \AppFramework \Utility \ITimeFactory ;
15+ use OCP \BackgroundJob \IJobList ;
1416use OCP \IURLGenerator ;
1517use OCP \IUser ;
1618use OCP \IUserManager ;
@@ -36,15 +38,19 @@ class Notifier implements INotifier, IDismissableNotifier {
3638 private $ userManager ;
3739 /** @var ITimeFactory */
3840 private $ timeFactory ;
41+ /** @var IJobList */
42+ private $ jobList ;
3943
4044 public function __construct (IFactory $ l10nFactory ,
4145 IURLGenerator $ urlGenerator ,
4246 TransferOwnershipMapper $ mapper ,
4347 IManager $ notificationManager ,
4448 IUserManager $ userManager ,
49+ IJobList $ jobList ,
4550 ITimeFactory $ timeFactory ) {
4651 $ this ->l10nFactory = $ l10nFactory ;
4752 $ this ->urlGenerator = $ urlGenerator ;
53+ $ this ->jobList = $ jobList ;
4854 $ this ->mapper = $ mapper ;
4955 $ this ->notificationManager = $ notificationManager ;
5056 $ this ->userManager = $ userManager ;
@@ -70,6 +76,10 @@ public function prepare(INotification $notification, string $languageCode): INot
7076 throw new UnknownNotificationException ('Unhandled app ' );
7177 }
7278
79+ $ imagePath = $ this ->urlGenerator ->imagePath ('files ' , 'folder-move.svg ' );
80+ $ iconUrl = $ this ->urlGenerator ->getAbsoluteURL ($ imagePath );
81+ $ notification ->setIcon ($ iconUrl );
82+
7383 return match ($ notification ->getSubject ()) {
7484 'transferownershipRequest ' => $ this ->handleTransferownershipRequest ($ notification , $ languageCode ),
7585 'transferownershipRequestDenied ' => $ this ->handleTransferOwnershipRequestDenied ($ notification , $ languageCode ),
@@ -259,6 +269,9 @@ public function dismissNotification(INotification $notification): void {
259269 if ($ notification ->getApp () !== 'files ' ) {
260270 throw new UnknownNotificationException ('Unhandled app ' );
261271 }
272+ if ($ notification ->getSubject () !== 'transferownershipRequest ' ) {
273+ throw new UnknownNotificationException ('Unhandled notification type ' );
274+ }
262275
263276 // TODO: This should all be moved to a service that also the transferownershipController uses.
264277 try {
@@ -267,6 +280,12 @@ public function dismissNotification(INotification $notification): void {
267280 return ;
268281 }
269282
283+ if ($ this ->jobList ->has (TransferOwnership::class, [
284+ 'id ' => $ transferOwnership ->getId (),
285+ ])) {
286+ return ;
287+ }
288+
270289 $ notification = $ this ->notificationManager ->createNotification ();
271290 $ notification ->setUser ($ transferOwnership ->getSourceUser ())
272291 ->setApp ('files ' )
0 commit comments