added nsfw flag to claims retrieval api

This commit is contained in:
Akinwale Ariwodola 2017-06-19 00:42:29 +01:00
parent 65924fdb3c
commit a2e9b8142e

View file

@ -14,6 +14,7 @@ class ClaimsController extends AppController {
$beforeId = intval($this->request->query('before')); $beforeId = intval($this->request->query('before'));
$afterId = intval($this->request->query('after')); $afterId = intval($this->request->query('after'));
$sort = trim($this->request->query('sort')); $sort = trim($this->request->query('sort'));
$nsfw = trim($this->request->query('nsfw'));
switch ($sort) { switch ($sort) {
case 'popular': case 'popular':
// TODO: sort by upvote/downvote score // TODO: sort by upvote/downvote score
@ -46,6 +47,10 @@ class ClaimsController extends AppController {
$conditions['Claims.Id <'] = $beforeId; $conditions['Claims.Id <'] = $beforeId;
} }
if ($nsfw !== 'true') {
$conditions['IsNSFW <>'] = 1;
}
$claims = $this->Claims->find()->contain(['Stream', 'Publisher' => ['fields' => ['Name']]])->distinct(['Claims.ClaimId'])->where($conditions)-> $claims = $this->Claims->find()->contain(['Stream', 'Publisher' => ['fields' => ['Name']]])->distinct(['Claims.ClaimId'])->where($conditions)->
limit($pageLimit)->order($order)->toArray(); limit($pageLimit)->order($order)->toArray();