$cc->displayError($e->getMessage());
}
+$subDb = new Subscriptions();
+
$url = $res->args['url'];
$url = Helper::addSchema($url);
$urlObj = new \Net_URL2($url);
$url = $urlObj->getNormalizedURL();
if (!Helper::isUrlAllowed($url)) {
- Log::error("Domain is not allowed; not crawling");
+ Log::error("Domain is not allowed; not subscribing");
+ $subDb->remove($url);
exit(2);
}
-$subDb = new Subscriptions();
-
list($topic, $hub) = $subDb->detectHub($url);
if ($hub === null) {
Log::error('No hub URL found for topic');
}
$sub = $subDb->get($topic);
-if ($sub !== false) {
- Log::error('Topic exists already in subscription table');
- Log::info('Current status: ' . $sub->sub_status);
- exit(3);
+if ($sub === false) {
+ $subDb->create($topic);
+} else {
+ Log::info(
+ 'Topic exists already in subscription table with status '
+ . $sub->sub_status
+ );
+ Log::info('Renewing subscription...');
+ $subDb->renew($sub->sub_id);
}
-$subDb->create($topic);
$sub = $subDb->get($topic);
$callbackUrl = $GLOBALS['phinde']['baseurl'] . 'push-subscription.php'