$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');
return $stmt->fetchObject();
}
+ /**
+ * Remove a topic
+ *
+ * @param string $topic Topic URL
+ *
+ * @return void
+ */
+ public function remove($topic)
+ {
+ $stmt = $this->db->prepare(
+ 'DELETE FROM subscriptions'
+ . ' WHERE sub_topic = :topic'
+ );
+ $stmt->execute([':topic' => $topic]);
+ }
+
/**
* Count number of subscriptions
*
{
$stmt = $this->db->prepare(
'SELECT * FROM subscriptions'
- . ' WHERE sub_status IN ("active", "expired")'
- . ' AND DATEDIFF(sub_expires, NOW()) <= 2'
+ . ' WHERE'
+ . '('
+ //expire soon
+ . ' sub_status IN ("active", "expired")'
+ . ' AND DATEDIFF(sub_expires, NOW()) <= 2'
+ . ') OR ('
+ //no reaction to subscription within 10 minutes
+ . ' sub_status = "subscribing"'
+ . ' AND TIMEDIFF(NOW(), sub_created) > "00:10:00"'
+ . ')'
);
$stmt->execute();