@ -459,7 +459,7 @@ class Database {
}
}
}
}
public function subscriptionAdd(string $user, string $url, string $fetchUser = "", string $fetchPassword = ""): int {
public function subscriptionAdd(string $user, string $url, string $fetchUser = "", string $fetchPassword = "", bool $discover = true ): int {
if (!Arsse::$user->authorize($user, __FUNCTION__)) {
if (!Arsse::$user->authorize($user, __FUNCTION__)) {
throw new User\ExceptionAuthz("notAuthorized", ["action" => __FUNCTION__, "user" => $user]);
throw new User\ExceptionAuthz("notAuthorized", ["action" => __FUNCTION__, "user" => $user]);
}
}
@ -470,7 +470,7 @@ class Database {
$feedID = $this->db->prepare('INSERT INTO arsse_feeds(url,username,password) values(?,?,?)', 'str', 'str', 'str')->run($url, $fetchUser, $fetchPassword)->lastId();
$feedID = $this->db->prepare('INSERT INTO arsse_feeds(url,username,password) values(?,?,?)', 'str', 'str', 'str')->run($url, $fetchUser, $fetchPassword)->lastId();
try {
try {
// perform an initial update on the newly added feed
// perform an initial update on the newly added feed
$this->feedUpdate($feedID, true);
$this->feedUpdate($feedID, true, $discover );
} catch (\Throwable $e) {
} catch (\Throwable $e) {
// if the update fails, delete the feed we just added
// if the update fails, delete the feed we just added
$this->db->prepare('DELETE from arsse_feeds where id is ?', 'int')->run($feedID);
$this->db->prepare('DELETE from arsse_feeds where id is ?', 'int')->run($feedID);
@ -601,7 +601,7 @@ class Database {
return array_column($feeds, 'id');
return array_column($feeds, 'id');
}
}
public function feedUpdate($feedID, bool $throwError = false): bool {
public function feedUpdate($feedID, bool $throwError = false, bool $discover = false ): bool {
$tr = $this->db->begin();
$tr = $this->db->begin();
// check to make sure the feed exists
// check to make sure the feed exists
if (!ValueInfo::id($feedID)) {
if (!ValueInfo::id($feedID)) {
@ -617,7 +617,7 @@ class Database {
// here. When an exception is thrown it should update the database with the
// here. When an exception is thrown it should update the database with the
// error instead of failing; if other exceptions are thrown, we should simply roll back
// error instead of failing; if other exceptions are thrown, we should simply roll back
try {
try {
$feed = new Feed((int) $feedID, $f['url'], (string) Date::transform($f['modified'], "http", "sql"), $f['etag'], $f['username'], $f['password'], $scrape);
$feed = new Feed((int) $feedID, $f['url'], (string) Date::transform($f['modified'], "http", "sql"), $f['etag'], $f['username'], $f['password'], $scrape, $discover );
if (!$feed->modified) {
if (!$feed->modified) {
// if the feed hasn't changed, just compute the next fetch time and record it
// if the feed hasn't changed, just compute the next fetch time and record it
$this->db->prepare("UPDATE arsse_feeds SET updated = CURRENT_TIMESTAMP, next_fetch = ? WHERE id is ?", 'datetime', 'int')->run($feed->nextFetch, $feedID);
$this->db->prepare("UPDATE arsse_feeds SET updated = CURRENT_TIMESTAMP, next_fetch = ? WHERE id is ?", 'datetime', 'int')->run($feed->nextFetch, $feedID);