@@ -343,7 +343,7 @@ function saveMenuFromAppV2($menu, $mobile)
343
343
$ retentionTime = config::byKey ('retentionTime ' , 'mobile ' , null );
344
344
if (isset ($ retentionTime ) && $ retentionTime != null ) {
345
345
log::add ('mobile ' , 'debug ' , '| [INFO] Nettoyage des notifs et images > ' );
346
- mobile::getNotificationsWithRetentioNTime ($ params ['Iq ' ], $ retentionTime );
346
+ mobile::cleaningNotifications ($ params ['Iq ' ], $ retentionTime );
347
347
}
348
348
349
349
$ jsonrpc ->makeSuccess ($ return );
@@ -676,85 +676,16 @@ function saveMenuFromAppV2($menu, $mobile)
676
676
if ($ jsonrpc ->getMethod () == 'getNotificationsFromFile ' ) {
677
677
log::add ('mobile ' , 'debug ' , '┌──────────▶︎ :fg-warning: Recuperation des Notifications :/fg: ────────── ' );
678
678
$ Iq = $ params ['Iq ' ];
679
-
680
- if (isset ($ params ['notifsTime ' ])){
681
- $ retentionTime = $ params ['notifsTime ' ];
682
- config::save ('retentionTime ' , $ retentionTime , 'mobile ' );
683
- log::add ('mobile ' , 'debug ' , '| Durée de retention actuelle : ' . $ retentionTime . ' jours ' );
684
- $ retentionSeconds = intVal ($ retentionTime ) * 24 * 60 * 60 ;
685
- $ currentTime = time ();
686
-
687
- $ pathImages = dirname (__FILE__ ) . '/../data/images/ ' ;
688
- if (is_dir ($ pathImages )){
689
- $ images = glob ($ pathImages . '*.jpg ' );
690
-
691
- foreach ($ images as $ image ) {
692
- $ fileCreationTime = filemtime ($ image );
693
- if ($ fileCreationTime < ($ currentTime - $ retentionSeconds )) {
694
- unlink ($ file );
695
- }
696
- }
697
- }
698
- }
699
-
700
-
701
-
702
679
$ filePath = dirname (__FILE__ ) . '/../data/notifications/ ' . $ Iq . '.json ' ;
703
680
$ notifications = 'noNotifications ' ;
704
681
if (file_exists ($ filePath )) {
705
682
$ notifications = file_get_contents ($ filePath );
706
- if ($ notifications ) {
707
- $ notifications = json_decode ($ notifications , true );
708
- $ notificationsModified = false ;
709
-
710
- foreach ($ notifications as $ id => $ value ) {
711
- $ notificationDate = strtotime ($ value ['data ' ]['date ' ]);
712
- if (isset ($ retentionSeconds )){
713
- if (($ currentTime - $ notificationDate ) > $ retentionSeconds ) {
714
- unset($ notifications [$ id ]);
715
- $ notificationsModified = true ;
716
- } else {
717
- $ dateNew = substr ($ value ['data ' ]['date ' ], 0 , 10 );
718
- $ horaire = substr ($ value ['data ' ]['date ' ], -8 );
719
- $ horaireFormat = substr ($ horaire , 0 , 5 );
720
- $ notifications [$ id ]['data ' ]['newDate ' ] = $ dateNew ;
721
- $ notifications [$ id ]['data ' ]['horaireFormat ' ] = $ horaireFormat ;
722
- }
723
- }else {
724
- $ dateNew = substr ($ value ['data ' ]['date ' ], 0 , 10 );
725
- $ horaire = substr ($ value ['data ' ]['date ' ], -8 );
726
- $ horaireFormat = substr ($ horaire , 0 , 5 );
727
- $ notifications [$ id ]['data ' ]['newDate ' ] = $ dateNew ;
728
- $ notifications [$ id ]['data ' ]['horaireFormat ' ] = $ horaireFormat ;
729
- }
730
- // if (($currentTime - $notificationDate) > $retentionSeconds) {
731
- // unset($notifications[$id]);
732
- // $notificationsModified = true;
733
- // } else {
734
- // $dateNew = substr($value['data']['date'], 0, 10);
735
- // $horaire = substr($value['data']['date'], -8);
736
- // $horaireFormat = substr($horaire, 0, 5);
737
- // $notifications[$id]['data']['newDate'] = $dateNew;
738
- // $notifications[$id]['data']['horaireFormat'] = $horaireFormat;
739
- // }
740
- }
741
- if ($ notificationsModified ) {
742
- file_put_contents ($ filePath , $ notifications );
743
- }
744
-
745
- $ notifications = json_encode ($ notifications );
746
- $ jsonrpc ->makeSuccess ($ notifications );
747
- log::add ('mobile ' , 'debug ' , '| [INFO] Notifications > ' . $ notifications );
748
- log::add ('mobile ' , 'debug ' , '└─────────────────────────────────────────── ' );
749
- }
750
-
751
683
}
752
-
753
- //$jsonrpc->makeSuccess($notifications );
754
-
684
+ log:: add ( ' mobile ' , ' debug ' , ' | [INFO] Notifications > ' . $ notifications );
685
+ log:: add ( ' mobile ' , ' debug ' , ' └─────────────────────────────────────────── ' );
686
+ $ jsonrpc -> makeSuccess ( $ notifications );
755
687
}
756
688
757
-
758
689
if ($ jsonrpc ->getMethod () == 'deleteNotificationInJsonFile ' ) {
759
690
log::add ('mobile ' , 'debug ' , '┌────▶︎ deleteNotificationInJsonFile ────── ' );
760
691
$ Iq = $ params ['Iq ' ];
@@ -772,8 +703,8 @@ function saveMenuFromAppV2($menu, $mobile)
772
703
$ notifications = json_encode ($ notificationsArray );
773
704
file_put_contents ($ filePath , $ notifications );
774
705
}
775
- log::add ('mobile ' , 'debug ' , '└─────────────────────────────────────────── ' );
776
706
}
707
+ log::add ('mobile ' , 'debug ' , '└─────────────────────────────────────────── ' );
777
708
$ jsonrpc ->makeSuccess ('ok ' );
778
709
}
779
710
0 commit comments