mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +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 {
|
||||
// check to make sure the feed exists
|
||||
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(
|
||||
"SELECT
|
||||
url, las_mod as modified, etag, err_count, scrape as scrapers, keep_rule, block_rule
|
||||
FROM arsse_subscriptions
|
||||
where id = ?",
|
||||
["int"]
|
||||
)->run($subID)->getRow();
|
||||
where id = ? and owner = coalesce(?, owner)",
|
||||
["int", "str"]
|
||||
)->run($subID, $user)->getRow();
|
||||
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
|
||||
$scrape = (Arsse::$conf->fetchEnableScraping && ($scrapeOverride ?? $f['scrapers']));
|
||||
|
|
|
@ -813,16 +813,14 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler {
|
|||
}
|
||||
|
||||
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 {
|
||||
Arsse::$db->feedAdd($data['feed_url'], (string) $data['username'], (string) $data['password'], false, (bool) $data['crawler']);
|
||||
$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']]);
|
||||
}
|
||||
$id = Arsse::$db->subscriptionAdd(Arsse::$user->id, $data['feed_url'], (string) $data['username'], (string) $data['password'], false, $properties);
|
||||
} catch (FeedException $e) {
|
||||
$msg = [
|
||||
10502 => "Fetch404",
|
||||
|
|
Loading…
Reference in a new issue