diff options
Diffstat (limited to 'apps/dav/lib/Comments/CommentsPlugin.php')
-rw-r--r-- | apps/dav/lib/Comments/CommentsPlugin.php | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/apps/dav/lib/Comments/CommentsPlugin.php b/apps/dav/lib/Comments/CommentsPlugin.php index 7db64313121..2ab7d6ee018 100644 --- a/apps/dav/lib/Comments/CommentsPlugin.php +++ b/apps/dav/lib/Comments/CommentsPlugin.php @@ -7,8 +7,10 @@ */ namespace OCA\DAV\Comments; +use OCP\AppFramework\Http; use OCP\Comments\IComment; use OCP\Comments\ICommentsManager; +use OCP\Comments\MessageTooLongException; use OCP\IUserSession; use Sabre\DAV\Exception\BadRequest; use Sabre\DAV\Exception\NotFound; @@ -34,24 +36,19 @@ class CommentsPlugin extends ServerPlugin { public const REPORT_PARAM_OFFSET = '{http://owncloud.org/ns}offset'; public const REPORT_PARAM_TIMESTAMP = '{http://owncloud.org/ns}datetime'; - /** @var ICommentsManager */ - protected $commentsManager; - /** @var \Sabre\DAV\Server $server */ private $server; - /** @var \OCP\IUserSession */ - protected $userSession; - /** * Comments plugin * * @param ICommentsManager $commentsManager * @param IUserSession $userSession */ - public function __construct(ICommentsManager $commentsManager, IUserSession $userSession) { - $this->commentsManager = $commentsManager; - $this->userSession = $userSession; + public function __construct( + protected ICommentsManager $commentsManager, + protected IUserSession $userSession, + ) { } /** @@ -73,7 +70,7 @@ class CommentsPlugin extends ServerPlugin { $this->server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc'; - $this->server->xml->classMap['DateTime'] = function (Writer $writer, \DateTime $value) { + $this->server->xml->classMap['DateTime'] = function (Writer $writer, \DateTime $value): void { $writer->write(\Sabre\HTTP\toDate($value)); }; @@ -112,7 +109,7 @@ class CommentsPlugin extends ServerPlugin { $response->setHeader('Content-Location', $url); // created - $response->setStatus(201); + $response->setStatus(Http::STATUS_CREATED); return false; } @@ -181,7 +178,7 @@ class CommentsPlugin extends ServerPlugin { new MultiStatus($responses) ); - $this->server->httpResponse->setStatus(207); + $this->server->httpResponse->setStatus(Http::STATUS_MULTI_STATUS); $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8'); $this->server->httpResponse->setBody($xml); @@ -216,7 +213,7 @@ class CommentsPlugin extends ServerPlugin { } } if (is_null($actorId)) { - throw new BadRequest('Invalid actor "' . $actorType .'"'); + throw new BadRequest('Invalid actor "' . $actorType . '"'); } try { @@ -227,9 +224,9 @@ class CommentsPlugin extends ServerPlugin { return $comment; } catch (\InvalidArgumentException $e) { throw new BadRequest('Invalid input values', 0, $e); - } catch (\OCP\Comments\MessageTooLongException $e) { + } catch (MessageTooLongException $e) { $msg = 'Message exceeds allowed character limit of '; - throw new BadRequest($msg . \OCP\Comments\IComment::MAX_MESSAGE_LENGTH, 0, $e); + throw new BadRequest($msg . IComment::MAX_MESSAGE_LENGTH, 0, $e); } } } |