Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 13 additions & 20 deletions lib/Cron/Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,25 @@
use OCP\IUser;
use OCP\Notification\IManager as INotificationManager;
use phpseclib\File\X509;
use Psr\Log\LoggerInterface;

class Crawler extends TimedJob {
public const FEED_URL = 'https://pushfeed.nextcloud.com/feed';

/** @var string */
protected $appName;
/** @var IConfig */
protected $config;
/** @var IGroupManager */
protected $groupManager;
/** @var INotificationManager */
protected $notificationManager;
/** @var IClientService */
protected $clientService;

/** @var array<array-key, bool> */
protected $notifyUsers = [];

public function __construct(string $appName,
public function __construct(
ITimeFactory $time,
IConfig $config,
IGroupManager $groupManager,
INotificationManager $notificationManager,
IClientService $clientService) {
protected string $appName,
protected IConfig $config,
protected IGroupManager $groupManager,
protected INotificationManager $notificationManager,
protected IClientService $clientService,
protected LoggerInterface $logger,
) {
parent::__construct($time);
$this->appName = $appName;
$this->config = $config;
$this->groupManager = $groupManager;
$this->notificationManager = $notificationManager;
$this->clientService = $clientService;

// Run once per day
$interval = 24 * 60 * 60;
Expand All @@ -61,6 +50,10 @@ public function __construct(string $appName,


protected function run(mixed $argument): void {
if ($this->config->getSystemValueBool('has_internet_connection', true) === false) {
$this->logger->info('This instance does not have Internet connection to access the Nextcloud feed platform.', ['app' => $this->appName]);
return;
}
try {
$feedBody = $this->loadFeed();
$rss = simplexml_load_string($feedBody);
Expand Down
Loading