@@ -189,7 +189,7 @@ public function prepare(INotification $notification, string $languageCode): INot
189189 case 'file_action_success ' :
190190 $ subject = $ l ->t ('File action has finished ' );
191191
192- $ sourceFileLink = $ this ->url ->linkToRouteAbsolute ('files.viewcontroller.showFile ' , ['fileid ' => $ params ['source_file_id ' ]]);
192+ $ targetDirLink = $ this ->url ->linkToRouteAbsolute ('files.viewcontroller.showFile ' , ['fileid ' => $ params ['source_file_id ' ]]);
193193 $ targetFileLink = $ this ->url ->linkToRouteAbsolute ('files.viewcontroller.showFile ' , ['fileid ' => $ params ['target_file_id ' ]]);
194194 $ taskLink = $ params ['target ' ];
195195 $ iconUrl = $ this ->url ->getAbsoluteURL ($ this ->url ->imagePath (Application::APP_ID , 'app-dark.svg ' ));
@@ -216,7 +216,7 @@ public function prepare(INotification $notification, string $languageCode): INot
216216 'id ' => (string )$ params ['source_file_id ' ],
217217 'name ' => $ params ['source_file_name ' ],
218218 'path ' => $ params ['source_file_path ' ],
219- 'link ' => $ sourceFileLink ,
219+ 'link ' => $ targetDirLink ,
220220 ],
221221 'targetFile ' => [
222222 'type ' => 'file ' ,
@@ -274,6 +274,70 @@ public function prepare(INotification $notification, string $languageCode): INot
274274
275275 return $ notification ;
276276
277+ case 'new_image_file_success ' :
278+ $ subject = $ l ->t ('New image file has been generated ' );
279+
280+ $ targetDirLink = $ this ->url ->linkToRouteAbsolute ('files.viewcontroller.showFile ' , ['fileid ' => $ params ['target_directory_id ' ]]);
281+ $ targetFileLink = $ this ->url ->linkToRouteAbsolute ('files.viewcontroller.showFile ' , ['fileid ' => $ params ['target_file_id ' ]]);
282+ $ taskLink = $ params ['target ' ];
283+ $ iconUrl = $ this ->url ->getAbsoluteURL ($ this ->url ->imagePath (Application::APP_ID , 'app-dark.svg ' ));
284+
285+ $ message = $ l ->t ('{targetFile} has been generated in {targetDirectory} ' );
286+
287+ $ notification
288+ ->setParsedSubject ($ subject )
289+ ->setRichMessage ($ message , [
290+ 'targetDirectory ' => [
291+ 'type ' => 'file ' ,
292+ 'id ' => (string )$ params ['target_directory_id ' ],
293+ 'name ' => $ params ['target_directory_name ' ],
294+ 'path ' => $ params ['target_directory_path ' ],
295+ 'link ' => $ targetDirLink ,
296+ ],
297+ 'targetFile ' => [
298+ 'type ' => 'file ' ,
299+ 'id ' => (string )$ params ['target_file_id ' ],
300+ 'name ' => $ params ['target_file_name ' ],
301+ 'path ' => $ params ['target_file_path ' ],
302+ 'link ' => $ targetFileLink ,
303+ ],
304+ ])
305+ ->setLink ($ taskLink )
306+ ->setIcon ($ iconUrl );
307+
308+ $ actionLabel = $ l ->t ('View results ' );
309+ $ action = $ notification ->createAction ();
310+ $ action ->setLabel ($ actionLabel )
311+ ->setParsedLabel ($ actionLabel )
312+ ->setLink ($ taskLink , IAction::TYPE_WEB )
313+ ->setPrimary (true );
314+
315+ $ notification ->addParsedAction ($ action );
316+
317+ return $ notification ;
318+
319+ case 'new_image_file_failure ' :
320+ $ subject = $ l ->t ('Image file generation has failed ' );
321+
322+ $ iconUrl = $ this ->url ->getAbsoluteURL ($ this ->url ->imagePath (Application::APP_ID , 'app-dark.svg ' ));
323+
324+ $ message = $ l ->t ('Generation of a new image file in {targetDirectory} has failed ' );
325+
326+ $ notification
327+ ->setParsedSubject ($ subject )
328+ ->setRichMessage ($ message , [
329+ 'targetDirectory ' => [
330+ 'type ' => 'file ' ,
331+ 'id ' => (string )$ params ['target_directory_id ' ],
332+ 'name ' => $ params ['target_directory_name ' ],
333+ 'path ' => $ params ['target_directory_path ' ],
334+ 'link ' => $ this ->url ->linkToRouteAbsolute ('files.viewcontroller.showFile ' , ['fileid ' => $ params ['target_directory_id ' ]]),
335+ ],
336+ ])
337+ ->setIcon ($ iconUrl );
338+
339+ return $ notification ;
340+
277341 default :
278342 // Unknown subject => Unknown notification => throw
279343 throw new InvalidArgumentException ();
0 commit comments