55namespace OCA \Libresign \Migration ;
66
77use OCA \Libresign \AppInfo \Application as AppInfoApplication ;
8+ use OCP \App \IAppManager ;
9+ use OCP \IConfig ;
10+ use OCP \IL10N ;
811use OCP \IUserManager ;
912use OCP \Migration \IOutput ;
1013use OCP \Migration \IRepairStep ;
@@ -14,6 +17,8 @@ class NotifyAdminsAfterUpgrade implements IRepairStep {
1417 public function __construct (
1518 private IUserManager $ userManager ,
1619 private NotificationManager $ notificationManager ,
20+ private IConfig $ config ,
21+ private IAppManager $ appManager ,
1722 ) {
1823 }
1924
@@ -22,6 +27,14 @@ public function getName(): string {
2227 }
2328
2429 public function run (IOutput $ output ): void {
30+
31+ $ currentVersion = $ currentVersion = $ this ->appManager ->getAppVersion (AppInfoApplication::APP_ID );
32+ $ lastNotifiedVersion = $ this ->config ->getAppValue (AppInfoApplication::APP_ID , 'last_notified_version ' , '' );
33+
34+ if ($ currentVersion === $ lastNotifiedVersion ) {
35+ return ;
36+ }
37+
2538 $ admins = $ this ->userManager ->search ('' , 1 , 0 , ['admin ' ]);
2639 foreach ($ admins as $ admin ) {
2740 $ notification = $ this ->notificationManager ->createNotification ();
@@ -31,9 +44,12 @@ public function run(IOutput $output): void {
3144 ->setDateTime (new \DateTime ())
3245 ->setObject ('upgrade ' , '1 ' )
3346 ->setSubject ('libresign_upgrade ' , [
34- 'message ' => 'LibreSign has been updated! Consider supporting the project: https://libresign.coop '
47+ 'message ' => 'LibreSign has been updated to version ' . $ currentVersion . ' ! Consider supporting the project: https://libresign.coop '
3548 ]);
3649 $ this ->notificationManager ->notify ($ notification );
3750 }
51+
52+ $ this ->config ->setAppValue (AppInfoApplication::APP_ID , 'last_notified_version ' , $ currentVersion );
3853 }
54+
3955}
0 commit comments