Merge pull request #774 from nextcloud/bugfix/771/rest-types

Fix numeric types and missing card id in card detail results
This commit is contained in:
Julius Härtl
2018-12-20 08:45:44 +01:00
committed by GitHub
5 changed files with 27 additions and 13 deletions
+8 -2
View File
@@ -24,12 +24,14 @@
namespace OCA\Deck\Controller; namespace OCA\Deck\Controller;
use OCA\Deck\StatusException;
use OCP\AppFramework\ApiController; use OCP\AppFramework\ApiController;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest; use OCP\IRequest;
use OCA\Deck\Service\BoardService; use OCA\Deck\Service\BoardService;
use Sabre\HTTP\Util;
/** /**
* Class BoardApiController * Class BoardApiController
@@ -61,10 +63,14 @@ class BoardApiController extends ApiController {
*/ */
public function index() { public function index() {
$modified = $this->request->getHeader('If-Modified-Since'); $modified = $this->request->getHeader('If-Modified-Since');
if ($modified === '') { if ($modified === null || $modified === '') {
$boards = $this->service->findAll(); $boards = $this->service->findAll();
} else { } else {
$boards = $this->service->findAll(strtotime($modified)); $date = Util::parseHTTPDate($modified);
if (!$date) {
throw new StatusException('Invalid If-Modified-Since header provided.');
}
$boards = $this->service->findAll($date->getTimestamp());
} }
return new DataResponse($boards, HTTP::STATUS_OK); return new DataResponse($boards, HTTP::STATUS_OK);
} }
+8 -2
View File
@@ -24,12 +24,14 @@
namespace OCA\Deck\Controller; namespace OCA\Deck\Controller;
use OCA\Deck\StatusException;
use OCP\AppFramework\ApiController; use OCP\AppFramework\ApiController;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest; use OCP\IRequest;
use OCA\Deck\Service\StackService; use OCA\Deck\Service\StackService;
use OCA\Deck\Service\BoardService; use OCA\Deck\Service\BoardService;
use Sabre\HTTP\Util;
/** /**
* Class StackApiController * Class StackApiController
@@ -62,8 +64,12 @@ class StackApiController extends ApiController {
public function index() { public function index() {
$since = 0; $since = 0;
$modified = $this->request->getHeader('If-Modified-Since'); $modified = $this->request->getHeader('If-Modified-Since');
if ($modified !== '') { if ($modified !== null && $modified !== '') {
$since = strtotime($modified); $date = Util::parseHTTPDate($modified);
if (!$date) {
throw new StatusException('Invalid If-Modified-Since header provided.');
}
$since = $date->getTimestamp();
} }
$stacks = $this->stackService->findAll($this->request->getParam('boardId'), $since); $stacks = $this->stackService->findAll($this->request->getParam('boardId'), $since);
return new DataResponse($stacks, HTTP::STATUS_OK); return new DataResponse($stacks, HTTP::STATUS_OK);
+1 -1
View File
@@ -33,7 +33,7 @@ class AssignedUsers extends RelationalEntity implements JsonSerializable {
public function __construct() { public function __construct() {
$this->addType('id', 'integer'); $this->addType('id', 'integer');
$this->addType('card_id', 'integer'); $this->addType('cardId', 'integer');
$this->addResolvable('participant'); $this->addResolvable('participant');
} }
+2
View File
@@ -32,5 +32,7 @@ class Label extends RelationalEntity {
public function __construct() { public function __construct() {
$this->addType('id', 'integer'); $this->addType('id', 'integer');
$this->addType('boardId', 'integer');
$this->addType('cardId', 'integer');
} }
} }
+1 -1
View File
@@ -45,7 +45,7 @@ class LabelMapper extends DeckMapper implements IPermissionMapper {
} }
public function findAssignedLabelsForCard($cardId, $limit = null, $offset = null) { public function findAssignedLabelsForCard($cardId, $limit = null, $offset = null) {
$sql = 'SELECT l.* FROM `*PREFIX*deck_assigned_labels` as al INNER JOIN *PREFIX*deck_labels as l ON l.id = al.label_id WHERE `card_id` = ? ORDER BY l.id'; $sql = 'SELECT l.*,card_id FROM `*PREFIX*deck_assigned_labels` as al INNER JOIN *PREFIX*deck_labels as l ON l.id = al.label_id WHERE `card_id` = ? ORDER BY l.id';
return $this->findEntities($sql, [$cardId], $limit, $offset); return $this->findEntities($sql, [$cardId], $limit, $offset);
} }
public function findAssignedLabelsForBoard($boardId, $limit = null, $offset = null) { public function findAssignedLabelsForBoard($boardId, $limit = null, $offset = null) {