From 6de894487cf21ff7d795b2a9d33594fc2d08235f Mon Sep 17 00:00:00 2001 From: Caluera Date: Sun, 10 Oct 2021 14:06:31 +0200 Subject: [PATCH 01/12] added expiration date and helper to resolveTicket --- lib/Service/TicketService.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Service/TicketService.php b/lib/Service/TicketService.php index 55d3787..03f5a48 100644 --- a/lib/Service/TicketService.php +++ b/lib/Service/TicketService.php @@ -79,12 +79,20 @@ class TicketService { $title = array_get($matrixTicketContent, "title", "Untitled"); $description = array_get($matrixTicketContent, "description", ""); $lastModified = $this->matrix->getLastEventDate($ticket->getMatrixRoom()); + $matrixHelperUser = $ticket->getMatrixHelperUser(); + $matrixHelperUserName = $matrixHelperUser ? "Helfer Name" : "nicht zugewiesen"; + //FIXME : set $maxHelpTime somewhere as an option or at least available for other functions + $maxHelpTime = 7 * 24 * 60 * 60 * 1000; + $expirationDate = $lastModified + $maxHelpTime; return array( 'ticketId' => $ticketId, 'status' => $ticket->getStatus(), 'lastModified' => $lastModified, 'title' => $title, 'description' => $description, + 'matrixHelperUser' => $matrixHelperUser, + 'matrixHelferName' => $matrixHelperUserName, + 'expirationDate' => $expirationDate ); } catch (MatrixException | RoomNotFoundException $e) { return array( From d7cdae5841fa30d28c35342eb0d4e7b20d4aa8e2 Mon Sep 17 00:00:00 2001 From: Caluera Date: Sun, 10 Oct 2021 14:09:16 +0200 Subject: [PATCH 02/12] delete unnecessary variable from return statement --- lib/Service/TicketService.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Service/TicketService.php b/lib/Service/TicketService.php index 03f5a48..a314630 100644 --- a/lib/Service/TicketService.php +++ b/lib/Service/TicketService.php @@ -90,7 +90,6 @@ class TicketService { 'lastModified' => $lastModified, 'title' => $title, 'description' => $description, - 'matrixHelperUser' => $matrixHelperUser, 'matrixHelferName' => $matrixHelperUserName, 'expirationDate' => $expirationDate ); From ae0ffa811f99d5ee49597ff70a01aed705377b0c Mon Sep 17 00:00:00 2001 From: Caluera Date: Sun, 10 Oct 2021 14:26:31 +0200 Subject: [PATCH 03/12] get all the values from the matrix --- lib/Service/TicketService.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/Service/TicketService.php b/lib/Service/TicketService.php index a314630..6f9dd20 100644 --- a/lib/Service/TicketService.php +++ b/lib/Service/TicketService.php @@ -68,6 +68,7 @@ class TicketService { } /** + * matrixTicketContent has all the syncronized data * @param MatrixTicket $ticket the database object. * @return array a JSON serializable representation of the resolved ticket, for the frontend. */ @@ -79,11 +80,8 @@ class TicketService { $title = array_get($matrixTicketContent, "title", "Untitled"); $description = array_get($matrixTicketContent, "description", ""); $lastModified = $this->matrix->getLastEventDate($ticket->getMatrixRoom()); - $matrixHelperUser = $ticket->getMatrixHelperUser(); - $matrixHelperUserName = $matrixHelperUser ? "Helfer Name" : "nicht zugewiesen"; - //FIXME : set $maxHelpTime somewhere as an option or at least available for other functions - $maxHelpTime = 7 * 24 * 60 * 60 * 1000; - $expirationDate = $lastModified + $maxHelpTime; + $matrixHelperUserName = array_get($matrixTicketContent, "matrixHelperUserName", "nicht zugewiesen"); + $expirationDate = array_get($matrixTicketContent, "expiration date", ""); return array( 'ticketId' => $ticketId, 'status' => $ticket->getStatus(), From 708136dcf745dd9bcbaca5ec9bfd6357112ebd9a Mon Sep 17 00:00:00 2001 From: Benedikt Ziemons Date: Sun, 10 Oct 2021 16:05:06 +0200 Subject: [PATCH 04/12] Add editorconfig for TABS! --- .editorconfig | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..708e5da --- /dev/null +++ b/.editorconfig @@ -0,0 +1,23 @@ +# Copyright 2017 Aviral Dasgupta +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +root = true + +[*] +charset=utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = tab +indent_size = 2 +trim_trailing_whitespace = true From 61ba02ccd95d09b640d0d78b9edf82c980cee7ae Mon Sep 17 00:00:00 2001 From: Benedikt Ziemons Date: Sun, 10 Oct 2021 19:01:00 +0200 Subject: [PATCH 05/12] Fix finding ticket by id with user Add findTicket by id only. --- composer.lock | 1 - lib/Controller/Errors.php | 4 +-- lib/Db/TicketMapper.php | 38 ++++++++++++++++++---- lib/Exceptions/TicketNotFoundException.php | 14 ++++++++ lib/Service/TicketService.php | 17 ++++++++-- src/App.vue | 11 ++----- 6 files changed, 66 insertions(+), 19 deletions(-) create mode 100644 lib/Exceptions/TicketNotFoundException.php diff --git a/composer.lock b/composer.lock index 1fdc435..880f52b 100644 --- a/composer.lock +++ b/composer.lock @@ -27,7 +27,6 @@ "phpunit/php-code-coverage": "^7.0", "phpunit/phpunit": "^8.5" }, - "default-branch": true, "type": "library", "extra": { "branch-alias": { diff --git a/lib/Controller/Errors.php b/lib/Controller/Errors.php index d118e8c..7fcb2d6 100644 --- a/lib/Controller/Errors.php +++ b/lib/Controller/Errors.php @@ -3,7 +3,7 @@ namespace OCA\UPschooling\Controller; use Closure; -use OCA\UPschooling\Service\NoteNotFound; +use OCA\UPschooling\Exceptions\TicketNotFoundException; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; @@ -11,7 +11,7 @@ trait Errors { protected function handleNotFound(Closure $callback): DataResponse { try { return new DataResponse($callback()); - } catch (NoteNotFound $e) { + } catch (TicketNotFoundException $e) { $message = ['message' => $e->getMessage()]; return new DataResponse($message, Http::STATUS_NOT_FOUND); } diff --git a/lib/Db/TicketMapper.php b/lib/Db/TicketMapper.php index 98a0a06..b7c1fc4 100644 --- a/lib/Db/TicketMapper.php +++ b/lib/Db/TicketMapper.php @@ -17,19 +17,40 @@ class TicketMapper extends QBMapper /** * @param int $id - * @param string $userId * @return Entity|MatrixTicket * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException * @throws DoesNotExistException */ - public function find(int $id, MatrixUser $matrixUser): MatrixTicket + public function findTicket(int $id): MatrixTicket { /* @var $qb IQueryBuilder */ $qb = $this->db->getQueryBuilder(); $qb->select('*') ->from('upschooling_tickets') - ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))) - ->andWhere($qb->expr()->in($matrixUser->getMatrixUser(), ['matrix_assisted_user', 'matrix_helper_user'])); + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))); + return $this->findEntity($qb); + } + + /** + * @param int $id + * @param string $userId + * @return Entity|MatrixTicket + * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException + * @throws DoesNotExistException + */ + public function findForUser(int $id, MatrixUser $matrixUser): MatrixTicket + { + /* @var $qb IQueryBuilder */ + $qb = $this->db->getQueryBuilder(); + $qb->select('*') + ->from('upschooling_tickets') + ->where( + $qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT)), + $qb->expr()->orX( + $qb->expr()->eq('matrix_assisted_user', $qb->createNamedParameter($matrixUser->getMatrixUser(), IQueryBuilder::PARAM_STR)), + $qb->expr()->eq('matrix_helper_user', $qb->createNamedParameter($matrixUser->getMatrixUser(), IQueryBuilder::PARAM_STR)) + ) + ); return $this->findEntity($qb); } @@ -37,13 +58,18 @@ class TicketMapper extends QBMapper * @param string $userId * @return array */ - public function findAll(MatrixUser $matrixUser): array + public function findAllForUser(MatrixUser $matrixUser): array { /* @var $qb IQueryBuilder */ $qb = $this->db->getQueryBuilder(); $qb->select('*') ->from('upschooling_tickets') - ->where($qb->expr()->in($matrixUser->getMatrixUser(), ['matrix_assisted_user', 'matrix_helper_user'])); + ->where( + $qb->expr()->orX( + $qb->expr()->eq('matrix_assisted_user', $qb->createNamedParameter($matrixUser->getMatrixUser(), IQueryBuilder::PARAM_STR)), + $qb->expr()->eq('matrix_helper_user', $qb->createNamedParameter($matrixUser->getMatrixUser(), IQueryBuilder::PARAM_STR)) + ) + ); return $this->findEntities($qb); } } diff --git a/lib/Exceptions/TicketNotFoundException.php b/lib/Exceptions/TicketNotFoundException.php new file mode 100644 index 0000000..22bfe1d --- /dev/null +++ b/lib/Exceptions/TicketNotFoundException.php @@ -0,0 +1,14 @@ +ticketMapper->findAll($this->getOrCreateUser($userId)); + $dbTickets = $this->ticketMapper->findAllForUser($this->getOrCreateUser($userId)); return array_map(function ($ticket) { return $this->resolveTicket($ticket); }, $dbTickets); } + /** + * @throws MatrixRequestException + * @throws MatrixHttpLibException + * @throws MultipleObjectsReturnedException + * @throws \OCP\DB\Exception + * @throws TicketNotFoundException + * @throws MatrixException + */ public function find($id, $userId): array { - return $this->resolveTicket($this->ticketMapper->find($id, $this->getOrCreateUser($userId))); + try { + return $this->resolveTicket($this->ticketMapper->findForUser($id, $this->getOrCreateUser($userId))); + } catch (DoesNotExistException $e) { + throw new TicketNotFoundException($id); + } } public function create($title, $content, $userId): array { diff --git a/src/App.vue b/src/App.vue index efff633..8d83029 100644 --- a/src/App.vue +++ b/src/App.vue @@ -61,15 +61,10 @@ export default { this.tickets.push(response.data) } }).catch(console.error) - axios.post( - 'api/v1/tickets', - { title: 'Zweites Ticket', content: 'Zweites Beispiel' }, + axios.get( + 'api/v1/tickets/1', { headers: { 'Content-Type': 'application/json', Accept: 'application/json' } }, - ).then((response) => { - if (this.ticketsFetched === false) { - this.tickets.push(response.data) - } - }).catch(console.error) + ).catch(console.error) }, fetchTickets() { axios.get( From e21aae4602370cafb724872994bc4302c08ce413 Mon Sep 17 00:00:00 2001 From: Caluera Date: Sun, 10 Oct 2021 14:06:31 +0200 Subject: [PATCH 06/12] added expiration date and helper to resolveTicket --- lib/Service/TicketService.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Service/TicketService.php b/lib/Service/TicketService.php index 1e15a36..e4fd7c6 100644 --- a/lib/Service/TicketService.php +++ b/lib/Service/TicketService.php @@ -92,12 +92,20 @@ class TicketService { $title = array_get($matrixTicketContent, "title", "Untitled"); $description = array_get($matrixTicketContent, "description", ""); $lastModified = $this->matrix->getLastEventDate($ticket->getMatrixRoom()); + $matrixHelperUser = $ticket->getMatrixHelperUser(); + $matrixHelperUserName = $matrixHelperUser ? "Helfer Name" : "nicht zugewiesen"; + //FIXME : set $maxHelpTime somewhere as an option or at least available for other functions + $maxHelpTime = 7 * 24 * 60 * 60 * 1000; + $expirationDate = $lastModified + $maxHelpTime; return array( 'ticketId' => $ticketId, 'status' => $ticket->getStatus(), 'lastModified' => $lastModified, 'title' => $title, 'description' => $description, + 'matrixHelperUser' => $matrixHelperUser, + 'matrixHelferName' => $matrixHelperUserName, + 'expirationDate' => $expirationDate ); } catch (MatrixException | RoomNotFoundException $e) { return array( From 8243b695ea9912beb3c5f11851f5c89346a3309f Mon Sep 17 00:00:00 2001 From: Caluera Date: Sun, 10 Oct 2021 14:09:16 +0200 Subject: [PATCH 07/12] delete unnecessary variable from return statement --- lib/Service/TicketService.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Service/TicketService.php b/lib/Service/TicketService.php index e4fd7c6..4cb4806 100644 --- a/lib/Service/TicketService.php +++ b/lib/Service/TicketService.php @@ -103,7 +103,6 @@ class TicketService { 'lastModified' => $lastModified, 'title' => $title, 'description' => $description, - 'matrixHelperUser' => $matrixHelperUser, 'matrixHelferName' => $matrixHelperUserName, 'expirationDate' => $expirationDate ); From d17e40e56b05bfce44ce1099319e0b0bf7e2bdc5 Mon Sep 17 00:00:00 2001 From: Caluera Date: Sun, 10 Oct 2021 14:26:31 +0200 Subject: [PATCH 08/12] get all the values from the matrix --- lib/Service/TicketService.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/Service/TicketService.php b/lib/Service/TicketService.php index 4cb4806..80843a1 100644 --- a/lib/Service/TicketService.php +++ b/lib/Service/TicketService.php @@ -81,6 +81,7 @@ class TicketService { } /** + * matrixTicketContent has all the syncronized data * @param MatrixTicket $ticket the database object. * @return array a JSON serializable representation of the resolved ticket, for the frontend. */ @@ -92,11 +93,8 @@ class TicketService { $title = array_get($matrixTicketContent, "title", "Untitled"); $description = array_get($matrixTicketContent, "description", ""); $lastModified = $this->matrix->getLastEventDate($ticket->getMatrixRoom()); - $matrixHelperUser = $ticket->getMatrixHelperUser(); - $matrixHelperUserName = $matrixHelperUser ? "Helfer Name" : "nicht zugewiesen"; - //FIXME : set $maxHelpTime somewhere as an option or at least available for other functions - $maxHelpTime = 7 * 24 * 60 * 60 * 1000; - $expirationDate = $lastModified + $maxHelpTime; + $matrixHelperUserName = array_get($matrixTicketContent, "matrixHelperUserName", "nicht zugewiesen"); + $expirationDate = array_get($matrixTicketContent, "expiration date", ""); return array( 'ticketId' => $ticketId, 'status' => $ticket->getStatus(), From 8e44a5ea517da8ceaaac7e10da64f573bdb92e9f Mon Sep 17 00:00:00 2001 From: Caluera Date: Sun, 10 Oct 2021 19:07:53 +0200 Subject: [PATCH 09/12] add function to assign a Helper to a ticket --- lib/Service/TicketService.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/Service/TicketService.php b/lib/Service/TicketService.php index 80843a1..4f82622 100644 --- a/lib/Service/TicketService.php +++ b/lib/Service/TicketService.php @@ -72,6 +72,19 @@ class TicketService { return $this->resolveTicket($this->ticketMapper->insert($ticket)); } + + + public function assign($id, $userId): array{ + $matrixUser = $this->getOrCreateUser($userId); + $ticket = $this->ticketMapper->findTicket($id); + $roomID= $ticket->getMatrixRoom(); + $this->matrix->setProperty($roomID, "upschooling.ticket", array( + "matrixHelperUser" => $matrixUser->getMatrixUser() + )); + $ticket->setMatrixHelperUser($matrixUser->getMatrixUser()); + return $this->resolveTicket($this->ticketMapper->update($ticket)); + } + public function update($id, $title, $content, $userId) { throw new Exception("Not implemented"); } @@ -93,7 +106,7 @@ class TicketService { $title = array_get($matrixTicketContent, "title", "Untitled"); $description = array_get($matrixTicketContent, "description", ""); $lastModified = $this->matrix->getLastEventDate($ticket->getMatrixRoom()); - $matrixHelperUserName = array_get($matrixTicketContent, "matrixHelperUserName", "nicht zugewiesen"); + $matrixHelperUser = array_get($matrixTicketContent, "matrixHelperUser", "nicht zugewiesen"); $expirationDate = array_get($matrixTicketContent, "expiration date", ""); return array( 'ticketId' => $ticketId, @@ -101,7 +114,7 @@ class TicketService { 'lastModified' => $lastModified, 'title' => $title, 'description' => $description, - 'matrixHelferName' => $matrixHelperUserName, + 'matrixHelperUser' => $matrixHelperUser, 'expirationDate' => $expirationDate ); } catch (MatrixException | RoomNotFoundException $e) { From 993e3d69b65d25106fc0ddd870147e90414dfc5a Mon Sep 17 00:00:00 2001 From: Caluera Date: Sun, 10 Oct 2021 19:12:26 +0200 Subject: [PATCH 10/12] add testing example in frontend for assigning a helper --- lib/Controller/TicketApiController.php | 8 ++++---- src/App.vue | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/Controller/TicketApiController.php b/lib/Controller/TicketApiController.php index bdaefb3..cd175d5 100644 --- a/lib/Controller/TicketApiController.php +++ b/lib/Controller/TicketApiController.php @@ -51,14 +51,14 @@ class TicketApiController extends ApiController return new DataResponse($this->service->create($title, $content, $this->userId)); } + + /** * @NoAdminRequired */ - public function update(int $id, string $title, string $content): DataResponse + public function update(): DataResponse { - return $this->handleNotFound(function () use ($id, $title, $content) { - return $this->service->update($id, $title, $content, $this->userId); - }); + return new DataResponse($this->service->assign(44,$this->userId)); } public function destroy(int $id): DataResponse diff --git a/src/App.vue b/src/App.vue index 8d83029..d93efd1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -65,6 +65,13 @@ export default { 'api/v1/tickets/1', { headers: { 'Content-Type': 'application/json', Accept: 'application/json' } }, ).catch(console.error) + axios.put( + 'api/v1/tickets/1', + {}, + { headers: { 'Content-Type': 'application/json', Accept: 'application/json' } } + ).then((response) => { + console.error('added a helper to ticket 2') + }).catch(console.error) }, fetchTickets() { axios.get( From f13c054aef8b5e8abb940b6388b67291576d9baf Mon Sep 17 00:00:00 2001 From: Caluera Date: Sun, 10 Oct 2021 19:21:39 +0200 Subject: [PATCH 11/12] fix merge conflict --- lib/Service/TicketService.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/Service/TicketService.php b/lib/Service/TicketService.php index d34bda5..b93f73a 100644 --- a/lib/Service/TicketService.php +++ b/lib/Service/TicketService.php @@ -106,11 +106,7 @@ class TicketService { $title = array_get($matrixTicketContent, "title", "Untitled"); $description = array_get($matrixTicketContent, "description", ""); $lastModified = $this->matrix->getLastEventDate($ticket->getMatrixRoom()); -<<<<<<< HEAD - $matrixHelperUser = array_get($matrixTicketContent, "matrixHelperUser", "nicht zugewiesen"); -======= - $matrixHelperUserName = array_get($matrixTicketContent, "matrixHelperUserName", "nicht zugewiesen"); ->>>>>>> ae0ffa811f99d5ee49597ff70a01aed705377b0c + $matrixHelperUser = array_get($matrixTicketContent, "matrixHelperUser", "nicht zugewiesen"); $expirationDate = array_get($matrixTicketContent, "expiration date", ""); return array( 'ticketId' => $ticketId, @@ -118,11 +114,7 @@ class TicketService { 'lastModified' => $lastModified, 'title' => $title, 'description' => $description, -<<<<<<< HEAD 'matrixHelperUser' => $matrixHelperUser, -======= - 'matrixHelferName' => $matrixHelperUserName, ->>>>>>> ae0ffa811f99d5ee49597ff70a01aed705377b0c 'expirationDate' => $expirationDate ); } catch (MatrixException | RoomNotFoundException $e) { From 2107a6f8e62945aac87716e54621cbef9a27c324 Mon Sep 17 00:00:00 2001 From: Benedikt Ziemons Date: Sun, 10 Oct 2021 19:49:36 +0200 Subject: [PATCH 12/12] Add helper name attribute in matrix room state --- lib/Controller/TicketApiController.php | 6 ++--- lib/Service/TicketService.php | 27 +++++++++++++------ .../Unit/Controller/NoteApiControllerTest.php | 4 +-- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/Controller/TicketApiController.php b/lib/Controller/TicketApiController.php index cd175d5..0f58359 100644 --- a/lib/Controller/TicketApiController.php +++ b/lib/Controller/TicketApiController.php @@ -51,14 +51,12 @@ class TicketApiController extends ApiController return new DataResponse($this->service->create($title, $content, $this->userId)); } - - /** * @NoAdminRequired */ - public function update(): DataResponse + public function update(int $id): DataResponse { - return new DataResponse($this->service->assign(44,$this->userId)); + return new DataResponse($this->service->assign($id, $this->userId)); } public function destroy(int $id): DataResponse diff --git a/lib/Service/TicketService.php b/lib/Service/TicketService.php index b93f73a..c241084 100644 --- a/lib/Service/TicketService.php +++ b/lib/Service/TicketService.php @@ -14,9 +14,13 @@ use OCA\UPschooling\Exceptions\RoomNotFoundException; use OCA\UPschooling\Exceptions\TicketNotFoundException; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\MultipleObjectsReturnedException; +use OCP\IUserManager; class TicketService { + /** @var IUserManager $userManager */ + private $userManager; + /** @var MatrixService */ private $matrix; @@ -26,7 +30,13 @@ class TicketService { /** @var UserMapper */ private $userMapper; - public function __construct(MatrixService $matrix, TicketMapper $ticketMapper, UserMapper $userMapper) { + public function __construct( + IUserManager $userManager, + MatrixService $matrix, + TicketMapper $ticketMapper, + UserMapper $userMapper + ) { + $this->userManager = $userManager; $this->matrix = $matrix; $this->ticketMapper = $ticketMapper; $this->userMapper = $userMapper; @@ -72,14 +82,14 @@ class TicketService { return $this->resolveTicket($this->ticketMapper->insert($ticket)); } - - public function assign($id, $userId): array{ $matrixUser = $this->getOrCreateUser($userId); $ticket = $this->ticketMapper->findTicket($id); - $roomID= $ticket->getMatrixRoom(); + $roomID = $ticket->getMatrixRoom(); + $helperName = $this->userManager->get($userId)->getDisplayName(); $this->matrix->setProperty($roomID, "upschooling.ticket", array( - "matrixHelperUser" => $matrixUser->getMatrixUser() + "matrixHelperUser" => $matrixUser->getMatrixUser(), + "matrixHelperName" => $helperName, )); $ticket->setMatrixHelperUser($matrixUser->getMatrixUser()); return $this->resolveTicket($this->ticketMapper->update($ticket)); @@ -107,15 +117,16 @@ class TicketService { $description = array_get($matrixTicketContent, "description", ""); $lastModified = $this->matrix->getLastEventDate($ticket->getMatrixRoom()); $matrixHelperUser = array_get($matrixTicketContent, "matrixHelperUser", "nicht zugewiesen"); - $expirationDate = array_get($matrixTicketContent, "expiration date", ""); + $matrixHelperName = array_get($matrixTicketContent, "matrixHelperName", $matrixHelperUser); + $expirationDate = array_get($matrixTicketContent, "expirationDate", ""); return array( 'ticketId' => $ticketId, 'status' => $ticket->getStatus(), 'lastModified' => $lastModified, 'title' => $title, 'description' => $description, - 'matrixHelperUser' => $matrixHelperUser, - 'expirationDate' => $expirationDate + 'matrixHelperName' => $matrixHelperName, + 'expirationDate' => $expirationDate ); } catch (MatrixException | RoomNotFoundException $e) { return array( diff --git a/tests/Unit/Controller/NoteApiControllerTest.php b/tests/Unit/Controller/NoteApiControllerTest.php index 3378322..3f9bb30 100644 --- a/tests/Unit/Controller/NoteApiControllerTest.php +++ b/tests/Unit/Controller/NoteApiControllerTest.php @@ -36,7 +36,7 @@ class NoteApiControllerTest extends TestCase $this->equalTo($this->userId)) ->will($this->returnValue($note)); - $result = $this->controller->update(3, 'title', 'content'); + $result = $this->controller->update(3); $this->assertEquals($note, $result->getData()); } @@ -49,7 +49,7 @@ class NoteApiControllerTest extends TestCase ->method('update') ->will($this->throwException(new NoteNotFound())); - $result = $this->controller->update(3, 'title', 'content'); + $result = $this->controller->update(3); $this->assertEquals(Http::STATUS_NOT_FOUND, $result->getStatus()); }