mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2025-01-08 17:02:41 +00:00
Small fixe-ups
- Process subscription addition in Miniflux correctly - Honour user stricture when updating feeds
This commit is contained in:
parent
ac38659e3a
commit
5129ed710b
2 changed files with 12 additions and 14 deletions
|
@ -1217,17 +1217,17 @@ class Database {
|
||||||
public function subscriptionUpdate(?string $user, $subID, bool $throwError = false): bool {
|
public function subscriptionUpdate(?string $user, $subID, bool $throwError = false): bool {
|
||||||
// check to make sure the feed exists
|
// check to make sure the feed exists
|
||||||
if (!V::id($subID)) {
|
if (!V::id($subID)) {
|
||||||
throw new Db\ExceptionInput("typeViolation", ["action" => __FUNCTION__, "field" => "feed", 'id' => $id, 'type' => "int > 0"]);
|
throw new Db\ExceptionInput("typeViolation", ["action" => __FUNCTION__, "field" => "feed", 'id' => $subID, 'type' => "int > 0"]);
|
||||||
}
|
}
|
||||||
$f = $this->db->prepareArray(
|
$f = $this->db->prepareArray(
|
||||||
"SELECT
|
"SELECT
|
||||||
url, las_mod as modified, etag, err_count, scrape as scrapers, keep_rule, block_rule
|
url, las_mod as modified, etag, err_count, scrape as scrapers, keep_rule, block_rule
|
||||||
FROM arsse_subscriptions
|
FROM arsse_subscriptions
|
||||||
where id = ?",
|
where id = ? and owner = coalesce(?, owner)",
|
||||||
["int"]
|
["int", "str"]
|
||||||
)->run($subID)->getRow();
|
)->run($subID, $user)->getRow();
|
||||||
if (!$f) {
|
if (!$f) {
|
||||||
throw new Db\ExceptionInput("subjectMissing", ["action" => __FUNCTION__, "field" => "feed", 'id' => $id]);
|
throw new Db\ExceptionInput("subjectMissing", ["action" => __FUNCTION__, "field" => "feed", 'id' => $subID]);
|
||||||
}
|
}
|
||||||
// determine whether the feed's items should be scraped for full content from the source Web site
|
// determine whether the feed's items should be scraped for full content from the source Web site
|
||||||
$scrape = (Arsse::$conf->fetchEnableScraping && ($scrapeOverride ?? $f['scrapers']));
|
$scrape = (Arsse::$conf->fetchEnableScraping && ($scrapeOverride ?? $f['scrapers']));
|
||||||
|
|
|
@ -813,16 +813,14 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createFeed(array $data): ResponseInterface {
|
protected function createFeed(array $data): ResponseInterface {
|
||||||
|
$properties = [
|
||||||
|
'folder' => $data['category_id'] - 1,
|
||||||
|
'scrape' => (bool) $data['crawler'],
|
||||||
|
'keep_rule' => $data['keeplist_rules'],
|
||||||
|
'block_rule' => $data['blocklist_rules'],
|
||||||
|
];
|
||||||
try {
|
try {
|
||||||
Arsse::$db->feedAdd($data['feed_url'], (string) $data['username'], (string) $data['password'], false, (bool) $data['crawler']);
|
$id = Arsse::$db->subscriptionAdd(Arsse::$user->id, $data['feed_url'], (string) $data['username'], (string) $data['password'], false, $properties);
|
||||||
$tr = Arsse::$db->begin();
|
|
||||||
$id = Arsse::$db->subscriptionAdd(Arsse::$user->id, $data['feed_url'], (string) $data['username'], (string) $data['password'], false, (bool) $data['crawler']);
|
|
||||||
Arsse::$db->subscriptionPropertiesSet(Arsse::$user->id, $id, ['folder' => $data['category_id'] - 1, 'scrape' => (bool) $data['crawler']]);
|
|
||||||
$tr->commit();
|
|
||||||
if (strlen($data['keeplist_rules'] ?? "") || strlen($data['blocklist_rules'] ?? "")) {
|
|
||||||
// we do rules separately so as not to tie up the database
|
|
||||||
Arsse::$db->subscriptionPropertiesSet(Arsse::$user->id, $id, ['keep_rule' => $data['keeplist_rules'], 'block_rule' => $data['blocklist_rules']]);
|
|
||||||
}
|
|
||||||
} catch (FeedException $e) {
|
} catch (FeedException $e) {
|
||||||
$msg = [
|
$msg = [
|
||||||
10502 => "Fetch404",
|
10502 => "Fetch404",
|
||||||
|
|
Loading…
Reference in a new issue