Skip to content

Commit 0947e85

Browse files
committed
fix cleanImages
1 parent 26c6154 commit 0947e85

File tree

2 files changed

+10
-28
lines changed

2 files changed

+10
-28
lines changed

core/api/mobile.api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ function saveMenuFromAppV2($menu, $mobile)
674674
}
675675

676676
if ($jsonrpc->getMethod() == 'getNotificationsFromFile') {
677-
log::add('mobile', 'debug', '┌────◀︎ getNotificationsFromFile ──────────');
677+
log::add('mobile', 'debug', '┌──────────▶︎ fg-warning: Recuperation des Notifications :/fg: ──────────');
678678
$Iq = $params['Iq'];
679679
$retentionTime = $params['notifsTime'];
680680

core/class/mobile.class.php

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public static function discovery_multi($cmds)
307307

308308

309309
public static function getNotificationsWithRetentioNTime($Iq, $retentionTime){
310-
log::add('mobile', 'debug', '┌────◀︎ getNotificationsFromFile ──────────');
310+
log::add('mobile', 'debug', '┌──────────▶︎ fg-warning: Nettoyage des Notifications et Images :/fg: ──────────');
311311

312312
log::add('mobile', 'debug', '| Durée de retention actuelle : '. $retentionTime . ' jours');
313313
$retentionSeconds = intVal($retentionTime) * 24 * 60 * 60;
@@ -316,11 +316,10 @@ public static function getNotificationsWithRetentioNTime($Iq, $retentionTime){
316316
$pathImages = dirname(__FILE__) . '/../data/images/';
317317
if(is_dir($pathImages)){
318318
$images = glob($pathImages . '*.jpg');
319-
320319
foreach ($images as $image) {
321320
$fileCreationTime = filemtime($image);
322321
if ($fileCreationTime < ($currentTime - $retentionSeconds)) {
323-
unlink($file);
322+
unlink($image);
324323
}
325324
}
326325
}
@@ -335,34 +334,17 @@ public static function getNotificationsWithRetentioNTime($Iq, $retentionTime){
335334

336335
foreach ($notifications as $id => $value) {
337336
$notificationDate = strtotime($value['data']['date']);
338-
if(isset($retentionSeconds)){
339-
if (($currentTime - $notificationDate) > $retentionSeconds) {
340-
unset($notifications[$id]);
341-
$notificationsModified = true;
342-
} else {
343-
$dateNew = substr($value['data']['date'], 0, 10);
344-
$horaire = substr($value['data']['date'], -8);
345-
$horaireFormat = substr($horaire, 0, 5);
346-
$notifications[$id]['data']['newDate'] = $dateNew;
347-
$notifications[$id]['data']['horaireFormat'] = $horaireFormat;
348-
}
349-
}else{
350-
$dateNew = substr($value['data']['date'], 0, 10);
351-
$horaire = substr($value['data']['date'], -8);
352-
$horaireFormat = substr($horaire, 0, 5);
353-
$notifications[$id]['data']['newDate'] = $dateNew;
354-
$notifications[$id]['data']['horaireFormat'] = $horaireFormat;
355-
}
337+
if (($currentTime - $notificationDate) > $retentionSeconds) {
338+
unset($notifications[$id]);
339+
$notificationsModified = true;
340+
}
356341
}
357-
if ($notificationsModified) {
358-
file_put_contents($filePath, $notifications);
359-
}
360-
$notifications = json_encode($notifications);
361-
log::add('mobile', 'debug', '| [INFO] Notifications > ' . $notifications);
362-
log::add('mobile', 'debug', '└───────────────────────────────────────────');
342+
363343
}
364344

365345
}
346+
log::add('mobile', 'debug', '| Fin du nettoyage des Notifications et Images');
347+
log::add('mobile', 'debug', '└───────────────────────────────────────────');
366348
}
367349

368350
public static function change_cmdAndeqLogic($_cmds, $_eqLogics)

0 commit comments

Comments
 (0)