From 11ae468c89eb78c4a862fe5670303513e1d2a3b1 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 26 Jan 2016 12:08:51 +0100 Subject: [PATCH] smaller changes related to reviews --- apps/dav/lib/comments/commentnode.php | 3 +- apps/dav/lib/comments/commentsplugin.php | 43 +++++++++--------------- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/apps/dav/lib/comments/commentnode.php b/apps/dav/lib/comments/commentnode.php index b78b4765ca..376c1bf327 100644 --- a/apps/dav/lib/comments/commentnode.php +++ b/apps/dav/lib/comments/commentnode.php @@ -135,8 +135,7 @@ class CommentNode implements \Sabre\DAV\INode, \Sabre\DAV\IProperties { * @return int */ function getLastModified() { - // we do not have a separate "mDateTime" field for updates currently. - return $this->comment->getCreationDateTime()->getTimestamp(); + return null; } /** diff --git a/apps/dav/lib/comments/commentsplugin.php b/apps/dav/lib/comments/commentsplugin.php index 59ce3f12f6..2f9b7bab59 100644 --- a/apps/dav/lib/comments/commentsplugin.php +++ b/apps/dav/lib/comments/commentsplugin.php @@ -103,31 +103,25 @@ class CommentsPlugin extends ServerPlugin { */ public function httpPost(RequestInterface $request, ResponseInterface $response) { $path = $request->getPath(); - - // Making sure the node exists - try { - $node = $this->server->tree->getNodeForPath($path); - } catch (NotFound $e) { + $node = $this->server->tree->getNodeForPath($path); + if (!$node instanceof EntityCollection) { return null; } - if ($node instanceof EntityCollection) { - $data = $request->getBodyAsString(); + $data = $request->getBodyAsString(); + $comment = $this->createComment( + $node->getName(), + $node->getId(), + $data, + $request->getHeader('Content-Type') + ); + $url = $request->getUrl() . '/' . urlencode($comment->getId()); - $comment = $this->createComment( - $node->getName(), - $node->getId(), - $data, - $request->getHeader('Content-Type') - ); - $url = $request->getUrl() . '/' . urlencode($comment->getId()); + $response->setHeader('Content-Location', $url); - $response->setHeader('Content-Location', $url); - - // created - $response->setStatus(201); - return false; - } + // created + $response->setStatus(201); + return false; } /** @@ -224,13 +218,8 @@ class CommentsPlugin extends ServerPlugin { try { $comment = $this->commentsManager->create($actorType, $actorId, $objectType, $objectId); - $properties = [ - 'message' => 'setMessage', - 'verb' => 'setVerb', - ]; - foreach($properties as $property => $setter) { - $comment->$setter($data[$property]); - } + $comment->setMessage($data['message']); + $comment->setVerb($data['verb']); $this->commentsManager->save($comment); return $comment; } catch (\InvalidArgumentException $e) {