1818use OCP \IUser ;
1919use OCP \Notification \IManager as INotificationManager ;
2020use phpseclib \File \X509 ;
21+ use Psr \Log \LoggerInterface ;
2122
2223class Crawler extends TimedJob {
2324 public const FEED_URL = 'https://pushfeed.nextcloud.com/feed ' ;
2425
25- /** @var string */
26- protected $ appName ;
27- /** @var IConfig */
28- protected $ config ;
29- /** @var IGroupManager */
30- protected $ groupManager ;
31- /** @var INotificationManager */
32- protected $ notificationManager ;
33- /** @var IClientService */
34- protected $ clientService ;
3526
3627 /** @var array<array-key, bool> */
3728 protected $ notifyUsers = [];
3829
39- public function __construct (string $ appName ,
30+ public function __construct (
4031 ITimeFactory $ time ,
41- IConfig $ config ,
42- IGroupManager $ groupManager ,
43- INotificationManager $ notificationManager ,
44- IClientService $ clientService ) {
32+ protected string $ appName ,
33+ protected IConfig $ config ,
34+ protected IGroupManager $ groupManager ,
35+ protected INotificationManager $ notificationManager ,
36+ protected IClientService $ clientService ,
37+ protected LoggerInterface $ logger ,
38+ ) {
4539 parent ::__construct ($ time );
46- $ this ->appName = $ appName ;
47- $ this ->config = $ config ;
48- $ this ->groupManager = $ groupManager ;
49- $ this ->notificationManager = $ notificationManager ;
50- $ this ->clientService = $ clientService ;
5140
5241 // Run once per day
5342 $ interval = 24 * 60 * 60 ;
@@ -61,6 +50,10 @@ public function __construct(string $appName,
6150
6251
6352 protected function run (mixed $ argument ): void {
53+ if ($ this ->config ->getSystemValueBool ('has_internet_connection ' , true ) === false ) {
54+ $ this ->logger ->info ('This instance does not have Internet connection to access the Nextcloud feed platform. ' , ['app ' => $ this ->appName ]);
55+ return ;
56+ }
6457 try {
6558 $ feedBody = $ this ->loadFeed ();
6659 $ rss = simplexml_load_string ($ feedBody );
0 commit comments