File tree Expand file tree Collapse file tree
modules/stato_servizi/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,7 +36,12 @@ public function response()
3636 $ message = "" ;
3737
3838 $ cache = Cache::where ('name ' , 'Informazioni su Services ' )->first ();
39- $ services = $ cache ->content ;
39+
40+ if (empty ($ cache ->content )) {
41+ $ services = Services::getInformazioni (true );
42+ } else {
43+ $ services = $ cache ->content ;
44+ }
4045
4146 //Filtra i risultati che hanno expiration_at fra oggi e $limite_scadenze
4247 $ servizi_in_scadenza = array_filter ($ services , function ($ service ) use ($ limite_scadenze ) {
Original file line number Diff line number Diff line change 2222
2323use Tasks \Manager ;
2424use API \Services ;
25- use Carbon \Carbon ;
26- use Models \Module ;
27- use Models \Cache ;
25+ use Tasks \Manager ;
2826
2927class ServicesHookTask extends Manager
3028{
@@ -33,26 +31,37 @@ class ServicesHookTask extends Manager
3331 public function execute ()
3432 {
3533 $ result = [
36- 'response ' => 1 ,
37- 'message ' => tr ('Controllo servizi attivi completato! ' ),
34+ 'response ' => 2 ,
35+ 'message ' => tr ('Token Services non configurato. Aggiornamento saltato. ' ),
3836 ];
3937
40- $ cache = Cache::where ('name ' , 'Informazioni su Services ' )->first ();
38+ if (!Services::isEnabled ()) {
39+ return $ result ;
40+ }
4141
4242 try {
43- if (Services::isEnabled ()) {
44- $ result = Services::getServiziAttivi ();
43+ $ informazioni = Services::getInformazioni (true );
44+
45+ if (!empty ($ informazioni )) {
46+ $ result = [
47+ 'response ' => 1 ,
48+ 'message ' => tr ('Controllo servizi attivi completato! ' ),
49+ ];
50+ } else {
51+ $ result = [
52+ 'response ' => 2 ,
53+ 'message ' => tr ('Risposta vuota dal servizio Services. Cache mantenuta. ' ),
54+ ];
4555 }
4656 } catch (\Exception $ e ) {
4757 $ result = [
48- 'response ' => 0 ,
49- 'message ' => tr ('Errore nel controllo dei servizi attivi! _error_ ' , [
58+ 'response ' => 2 ,
59+ 'message ' => tr ('Errore nel controllo dei servizi attivi! _error_. Cache mantenuta. ' , [
5060 '_error_ ' => $ e ->getMessage (),
5161 ]),
5262 ];
5363 }
5464
55- $ cache ->set ($ result );
5665 return $ result ;
5766 }
5867}
You can’t perform that action at this time.
0 commit comments