mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Cleanup
This commit is contained in:
parent
dd24246f49
commit
2332cd52a3
4 changed files with 29 additions and 25 deletions
|
@ -20,6 +20,8 @@
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.0",
|
"php": "^7.0",
|
||||||
"ext-intl": "*",
|
"ext-intl": "*",
|
||||||
|
"ext-json": "*",
|
||||||
|
"ext-hash": "*",
|
||||||
"fguillot/picofeed": ">=0.1.31",
|
"fguillot/picofeed": ">=0.1.31",
|
||||||
"jkingweb/druuid": "^3.0.0",
|
"jkingweb/druuid": "^3.0.0",
|
||||||
"phpseclib/phpseclib": "^2.0.4",
|
"phpseclib/phpseclib": "^2.0.4",
|
||||||
|
|
6
composer.lock
generated
6
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "716302e991c06ae6308829749b16a078",
|
"content-hash": "16548deb9ff155dc6c48bbfe664bf4a0",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "fguillot/picofeed",
|
"name": "fguillot/picofeed",
|
||||||
|
@ -1787,7 +1787,9 @@
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": "^7.0",
|
"php": "^7.0",
|
||||||
"ext-intl": "*"
|
"ext-intl": "*",
|
||||||
|
"ext-json": "*",
|
||||||
|
"ext-hash": "*"
|
||||||
},
|
},
|
||||||
"platform-dev": []
|
"platform-dev": []
|
||||||
}
|
}
|
||||||
|
|
|
@ -449,28 +449,6 @@ class Database {
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function articleStarredCount(string $user, array $context = []): int {
|
|
||||||
if(!Data::$user->authorize($user, __FUNCTION__)) throw new User\ExceptionAuthz("notAuthorized", ["action" => __FUNCTION__, "user" => $user]);
|
|
||||||
return $this->db->prepare("SELECT count(*) from arsse_marks where owner is ? and starred is 1", "str")->run($user)->getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function editionLatest(string $user, array $context = []): int {
|
|
||||||
if(!Data::$user->authorize($user, __FUNCTION__)) throw new User\ExceptionAuthz("notAuthorized", ["action" => __FUNCTION__, "user" => $user]);
|
|
||||||
if(array_key_exists("subscription", $context)) {
|
|
||||||
$id = $context['subscription'];
|
|
||||||
$sub = $this->subscriptionValidateId($user, $id);
|
|
||||||
return (int) $this->db->prepare(
|
|
||||||
"SELECT max(arsse_editions.id)
|
|
||||||
from arsse_editions
|
|
||||||
left join arsse_articles on article is arsse_articles.id
|
|
||||||
left join arsse_feeds on arsse_articles.feed is arsse_feeds.id
|
|
||||||
where arsse_feeds.id is ?",
|
|
||||||
"int"
|
|
||||||
)->run($sub['feed'])->getValue();
|
|
||||||
}
|
|
||||||
return (int) $this->db->prepare("SELECT max(id) from arsse_editions")->run()->getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function feedListStale(): array {
|
public function feedListStale(): array {
|
||||||
$feeds = $this->db->prepare("SELECT id from arsse_feeds where next_fetch <= CURRENT_TIMESTAMP")->run()->getAll();
|
$feeds = $this->db->prepare("SELECT id from arsse_feeds where next_fetch <= CURRENT_TIMESTAMP")->run()->getAll();
|
||||||
return array_column($feeds,'id');
|
return array_column($feeds,'id');
|
||||||
|
@ -608,4 +586,26 @@ class Database {
|
||||||
'int', $tId, $tHashUT, $tHashUC, $tHashTC
|
'int', $tId, $tHashUT, $tHashUC, $tHashTC
|
||||||
)->run($feedID, $ids, $hashesUT, $hashesUC, $hashesTC);
|
)->run($feedID, $ids, $hashesUT, $hashesUC, $hashesTC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function articleStarredCount(string $user, array $context = []): int {
|
||||||
|
if(!Data::$user->authorize($user, __FUNCTION__)) throw new User\ExceptionAuthz("notAuthorized", ["action" => __FUNCTION__, "user" => $user]);
|
||||||
|
return $this->db->prepare("SELECT count(*) from arsse_marks where owner is ? and starred is 1", "str")->run($user)->getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function editionLatest(string $user, array $context = []): int {
|
||||||
|
if(!Data::$user->authorize($user, __FUNCTION__)) throw new User\ExceptionAuthz("notAuthorized", ["action" => __FUNCTION__, "user" => $user]);
|
||||||
|
if(array_key_exists("subscription", $context)) {
|
||||||
|
$id = $context['subscription'];
|
||||||
|
$sub = $this->subscriptionValidateId($user, $id);
|
||||||
|
return (int) $this->db->prepare(
|
||||||
|
"SELECT max(arsse_editions.id)
|
||||||
|
from arsse_editions
|
||||||
|
left join arsse_articles on article is arsse_articles.id
|
||||||
|
left join arsse_feeds on arsse_articles.feed is arsse_feeds.id
|
||||||
|
where arsse_feeds.id is ?",
|
||||||
|
"int"
|
||||||
|
)->run($sub['feed'])->getValue();
|
||||||
|
}
|
||||||
|
return (int) $this->db->prepare("SELECT max(id) from arsse_editions")->run()->getValue();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -393,7 +393,7 @@ class TestNCNV1_2 extends \PHPUnit\Framework\TestCase {
|
||||||
$this->assertEquals($exp, $this->h->dispatch(new Request("GET", "/feeds/update", json_encode($in[2]), 'application/json')));
|
$this->assertEquals($exp, $this->h->dispatch(new Request("GET", "/feeds/update", json_encode($in[2]), 'application/json')));
|
||||||
$exp = new Response(422);
|
$exp = new Response(422);
|
||||||
$this->assertEquals($exp, $this->h->dispatch(new Request("GET", "/feeds/update", json_encode($in[3]), 'application/json')));
|
$this->assertEquals($exp, $this->h->dispatch(new Request("GET", "/feeds/update", json_encode($in[3]), 'application/json')));
|
||||||
// retrieving the list when not an admin fails
|
// updating a feed when not an admin fails
|
||||||
Phake::when(Data::$user)->rightsGet->thenReturn(0);
|
Phake::when(Data::$user)->rightsGet->thenReturn(0);
|
||||||
$exp = new Response(403);
|
$exp = new Response(403);
|
||||||
$this->assertEquals($exp, $this->h->dispatch(new Request("GET", "/feeds/update", json_encode($in[0]), 'application/json')));
|
$this->assertEquals($exp, $this->h->dispatch(new Request("GET", "/feeds/update", json_encode($in[0]), 'application/json')));
|
||||||
|
|
Loading…
Reference in a new issue