aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorGit'Fellow <12234510+solracsf@users.noreply.github.com>2024-12-14 10:32:14 +0100
committerGit'Fellow <12234510+solracsf@users.noreply.github.com>2024-12-14 11:23:29 +0100
commit36d6b0f1e6eae58e20f35bb9d87671d338ea0a61 (patch)
tree5b615ccd1b9425476515f9786b0d81ba86fee903 /apps
parentafc4b0aea5103fad469bd27d1d199778f956291c (diff)
downloadnextcloud-server-36d6b0f1e6eae58e20f35bb9d87671d338ea0a61.tar.gz
nextcloud-server-36d6b0f1e6eae58e20f35bb9d87671d338ea0a61.zip
refactor: Use Http framework where possibleuseHttpFramework
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/CalDAV/BirthdayCalendar/EnablePlugin.php7
-rw-r--r--apps/dav/lib/CalDAV/Publishing/PublishPlugin.php5
-rw-r--r--apps/dav/lib/CalDAV/Search/SearchPlugin.php3
-rw-r--r--apps/dav/lib/CardDAV/ImageExportPlugin.php7
-rw-r--r--apps/dav/lib/CardDAV/MultiGetExportPlugin.php3
-rw-r--r--apps/dav/lib/Comments/CommentsPlugin.php5
-rw-r--r--apps/dav/lib/Connector/Sabre/Auth.php15
-rw-r--r--apps/dav/lib/Connector/Sabre/BearerAuth.php3
-rw-r--r--apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php3
-rw-r--r--apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php3
-rw-r--r--apps/dav/lib/Connector/Sabre/FakeLockerPlugin.php12
-rw-r--r--apps/dav/lib/Connector/Sabre/FilesReportPlugin.php3
-rw-r--r--apps/dav/lib/DAV/Sharing/Plugin.php3
-rw-r--r--apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php11
-rw-r--r--apps/dav/lib/SystemTag/SystemTagPlugin.php13
-rw-r--r--apps/dav/lib/Upload/ChunkingPlugin.php3
-rw-r--r--apps/dav/lib/Upload/ChunkingV2Plugin.php5
17 files changed, 57 insertions, 47 deletions
diff --git a/apps/dav/lib/CalDAV/BirthdayCalendar/EnablePlugin.php b/apps/dav/lib/CalDAV/BirthdayCalendar/EnablePlugin.php
index b323673969b..cd0b58c53d2 100644
--- a/apps/dav/lib/CalDAV/BirthdayCalendar/EnablePlugin.php
+++ b/apps/dav/lib/CalDAV/BirthdayCalendar/EnablePlugin.php
@@ -7,6 +7,7 @@ namespace OCA\DAV\CalDAV\BirthdayCalendar;
use OCA\DAV\CalDAV\BirthdayService;
use OCA\DAV\CalDAV\CalendarHome;
+use OCP\AppFramework\Http;
use OCP\IConfig;
use OCP\IUser;
use Sabre\DAV\Server;
@@ -92,7 +93,7 @@ class EnablePlugin extends ServerPlugin {
*/
public function httpPost(RequestInterface $request, ResponseInterface $response) {
$node = $this->server->tree->getNodeForPath($this->server->getRequestUri());
- if (!($node instanceof CalendarHome)) {
+ if (!$node instanceof CalendarHome) {
return;
}
@@ -104,14 +105,14 @@ class EnablePlugin extends ServerPlugin {
$owner = substr($node->getOwner(), 17);
if ($owner !== $this->user->getUID()) {
- $this->server->httpResponse->setStatus(403);
+ $this->server->httpResponse->setStatus(Http::STATUS_FORBIDDEN);
return false;
}
$this->config->setUserValue($this->user->getUID(), 'dav', 'generateBirthdayCalendar', 'yes');
$this->birthdayService->syncUser($this->user->getUID());
- $this->server->httpResponse->setStatus(204);
+ $this->server->httpResponse->setStatus(Http::STATUS_NO_CONTENT);
return false;
}
diff --git a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
index 1916187af2b..db73a761b0d 100644
--- a/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
+++ b/apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
@@ -7,6 +7,7 @@ namespace OCA\DAV\CalDAV\Publishing;
use OCA\DAV\CalDAV\Calendar;
use OCA\DAV\CalDAV\Publishing\Xml\Publisher;
+use OCP\AppFramework\Http;
use OCP\IConfig;
use OCP\IURLGenerator;
use Sabre\CalDAV\Xml\Property\AllowedSharingModes;
@@ -179,7 +180,7 @@ class PublishPlugin extends ServerPlugin {
$node->setPublishStatus(true);
// iCloud sends back the 202, so we will too.
- $response->setStatus(202);
+ $response->setStatus(Http::STATUS_ACCEPTED);
// Adding this because sending a response body may cause issues,
// and I wanted some type of indicator the response was handled.
@@ -213,7 +214,7 @@ class PublishPlugin extends ServerPlugin {
$node->setPublishStatus(false);
- $response->setStatus(200);
+ $response->setStatus(Http::STATUS_OK);
// Adding this because sending a response body may cause issues,
// and I wanted some type of indicator the response was handled.
diff --git a/apps/dav/lib/CalDAV/Search/SearchPlugin.php b/apps/dav/lib/CalDAV/Search/SearchPlugin.php
index c69537523f2..602ce151e12 100644
--- a/apps/dav/lib/CalDAV/Search/SearchPlugin.php
+++ b/apps/dav/lib/CalDAV/Search/SearchPlugin.php
@@ -7,6 +7,7 @@ namespace OCA\DAV\CalDAV\Search;
use OCA\DAV\CalDAV\CalendarHome;
use OCA\DAV\CalDAV\Search\Xml\Request\CalendarSearchReport;
+use OCP\AppFramework\Http;
use Sabre\DAV\Server;
use Sabre\DAV\ServerPlugin;
@@ -133,7 +134,7 @@ class SearchPlugin extends ServerPlugin {
$prefer = $this->server->getHTTPPrefer();
- $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->setHeader('Vary', 'Brief,Prefer');
diff --git a/apps/dav/lib/CardDAV/ImageExportPlugin.php b/apps/dav/lib/CardDAV/ImageExportPlugin.php
index 8a950202c08..74a8b032e42 100644
--- a/apps/dav/lib/CardDAV/ImageExportPlugin.php
+++ b/apps/dav/lib/CardDAV/ImageExportPlugin.php
@@ -7,6 +7,7 @@
*/
namespace OCA\DAV\CardDAV;
+use OCP\AppFramework\Http;
use OCP\Files\NotFoundException;
use Sabre\CardDAV\Card;
use Sabre\DAV\Server;
@@ -59,7 +60,7 @@ class ImageExportPlugin extends ServerPlugin {
$path = $request->getPath();
$node = $this->server->tree->getNodeForPath($path);
- if (!($node instanceof Card)) {
+ if (!$node instanceof Card) {
return true;
}
@@ -86,11 +87,11 @@ class ImageExportPlugin extends ServerPlugin {
$response->setHeader('Content-Type', $file->getMimeType());
$fileName = $node->getName() . '.' . PhotoCache::ALLOWED_CONTENT_TYPES[$file->getMimeType()];
$response->setHeader('Content-Disposition', "attachment; filename=$fileName");
- $response->setStatus(200);
+ $response->setStatus(Http::STATUS_OK);
$response->setBody($file->getContent());
} catch (NotFoundException $e) {
- $response->setStatus(\OCP\AppFramework\Http::STATUS_NO_CONTENT);
+ $response->setStatus(Http::STATUS_NO_CONTENT);
}
return false;
diff --git a/apps/dav/lib/CardDAV/MultiGetExportPlugin.php b/apps/dav/lib/CardDAV/MultiGetExportPlugin.php
index 524ed4d433c..9d6b0df838e 100644
--- a/apps/dav/lib/CardDAV/MultiGetExportPlugin.php
+++ b/apps/dav/lib/CardDAV/MultiGetExportPlugin.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
*/
namespace OCA\DAV\CardDAV;
+use OCP\AppFramework\Http;
use Sabre\DAV;
use Sabre\DAV\Server;
use Sabre\HTTP\RequestInterface;
@@ -65,7 +66,7 @@ class MultiGetExportPlugin extends DAV\ServerPlugin {
$response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
$response->setHeader('Content-Type', 'text/vcard');
- $response->setStatus(200);
+ $response->setStatus(Http::STATUS_OK);
$response->setBody($output);
return true;
diff --git a/apps/dav/lib/Comments/CommentsPlugin.php b/apps/dav/lib/Comments/CommentsPlugin.php
index 92ffae3f73e..2ab7d6ee018 100644
--- a/apps/dav/lib/Comments/CommentsPlugin.php
+++ b/apps/dav/lib/Comments/CommentsPlugin.php
@@ -7,6 +7,7 @@
*/
namespace OCA\DAV\Comments;
+use OCP\AppFramework\Http;
use OCP\Comments\IComment;
use OCP\Comments\ICommentsManager;
use OCP\Comments\MessageTooLongException;
@@ -108,7 +109,7 @@ class CommentsPlugin extends ServerPlugin {
$response->setHeader('Content-Location', $url);
// created
- $response->setStatus(201);
+ $response->setStatus(Http::STATUS_CREATED);
return false;
}
@@ -177,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);
diff --git a/apps/dav/lib/Connector/Sabre/Auth.php b/apps/dav/lib/Connector/Sabre/Auth.php
index fa1c2e95fad..66c41262d54 100644
--- a/apps/dav/lib/Connector/Sabre/Auth.php
+++ b/apps/dav/lib/Connector/Sabre/Auth.php
@@ -13,6 +13,7 @@ use OC\Authentication\TwoFactorAuth\Manager;
use OC\User\Session;
use OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden;
use OCA\DAV\Connector\Sabre\Exception\TooManyRequests;
+use OCP\AppFramework\Http;
use OCP\Defaults;
use OCP\IRequest;
use OCP\ISession;
@@ -27,20 +28,16 @@ use Sabre\HTTP\ResponseInterface;
class Auth extends AbstractBasic {
public const DAV_AUTHENTICATED = 'AUTHENTICATED_TO_DAV_BACKEND';
- private Session $userSession;
private ?string $currentUser = null;
- private Manager $twoFactorManager;
public function __construct(
private ISession $session,
- Session $userSession,
+ private Session $userSession,
private IRequest $request,
- Manager $twoFactorManager,
+ private Manager $twoFactorManager,
private IThrottler $throttler,
string $principalPrefix = 'principals/users/',
) {
- $this->userSession = $userSession;
- $this->twoFactorManager = $twoFactorManager;
$this->principalPrefix = $principalPrefix;
// setup realm
@@ -111,7 +108,7 @@ class Auth extends AbstractBasic {
} catch (Exception $e) {
$class = get_class($e);
$msg = $e->getMessage();
- \OC::$server->get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
+ \OCP\Server::get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
throw new ServiceUnavailable("$class: $msg");
}
}
@@ -166,7 +163,7 @@ class Auth extends AbstractBasic {
if ($this->request->getMethod() === 'POST') {
$forcedLogout = true;
} else {
- $response->setStatus(401);
+ $response->setStatus(Http::STATUS_UNAUTHORIZED);
throw new \Sabre\DAV\Exception\NotAuthenticated('CSRF check not passed.');
}
}
@@ -199,7 +196,7 @@ class Auth extends AbstractBasic {
} elseif (in_array('XMLHttpRequest', explode(',', $request->getHeader('X-Requested-With') ?? ''))) {
// For ajax requests use dummy auth name to prevent browser popup in case of invalid creditials
$response->addHeader('WWW-Authenticate', 'DummyBasic realm="' . $this->realm . '"');
- $response->setStatus(401);
+ $response->setStatus(Http::STATUS_UNAUTHORIZED);
throw new \Sabre\DAV\Exception\NotAuthenticated('Cannot authenticate over ajax calls');
}
return $data;
diff --git a/apps/dav/lib/Connector/Sabre/BearerAuth.php b/apps/dav/lib/Connector/Sabre/BearerAuth.php
index 1b85a971553..07bb3e052a5 100644
--- a/apps/dav/lib/Connector/Sabre/BearerAuth.php
+++ b/apps/dav/lib/Connector/Sabre/BearerAuth.php
@@ -5,6 +5,7 @@
*/
namespace OCA\DAV\Connector\Sabre;
+use OCP\AppFramework\Http;
use OCP\Defaults;
use OCP\IRequest;
use OCP\ISession;
@@ -56,6 +57,6 @@ class BearerAuth extends AbstractBearer {
* @param ResponseInterface $response
*/
public function challenge(RequestInterface $request, ResponseInterface $response): void {
- $response->setStatus(401);
+ $response->setStatus(Http::STATUS_UNAUTHORIZED);
}
}
diff --git a/apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php b/apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php
index 1bf45b22537..64a61a43a9b 100644
--- a/apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php
+++ b/apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php
@@ -8,6 +8,7 @@ declare(strict_types=1);
namespace OCA\DAV\Connector\Sabre;
+use OCP\AppFramework\Http;
use Sabre\DAV\Server;
use Sabre\DAV\ServerPlugin;
use Sabre\HTTP\RequestInterface;
@@ -59,7 +60,7 @@ class ChecksumUpdatePlugin extends ServerPlugin {
$node->setChecksum($checksum);
$response->addHeader('OC-Checksum', $checksum);
$response->setHeader('Content-Length', '0');
- $response->setStatus(204);
+ $response->setStatus(Http::STATUS_NO_CONTENT);
return false;
}
diff --git a/apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php b/apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php
index 26819836001..4a7e30caa10 100644
--- a/apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php
+++ b/apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php
@@ -7,6 +7,7 @@
*/
namespace OCA\DAV\Connector\Sabre;
+use OCP\AppFramework\Http;
use Sabre\DAV\Server;
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
@@ -48,7 +49,7 @@ class DummyGetResponsePlugin extends \Sabre\DAV\ServerPlugin {
fwrite($stream, $string);
rewind($stream);
- $response->setStatus(200);
+ $response->setStatus(Http::STATUS_OK);
$response->setBody($stream);
return false;
diff --git a/apps/dav/lib/Connector/Sabre/FakeLockerPlugin.php b/apps/dav/lib/Connector/Sabre/FakeLockerPlugin.php
index 485b6b09a3c..61ecfaf845c 100644
--- a/apps/dav/lib/Connector/Sabre/FakeLockerPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FakeLockerPlugin.php
@@ -7,9 +7,11 @@
*/
namespace OCA\DAV\Connector\Sabre;
+use OCP\AppFramework\Http;
use Sabre\DAV\INode;
use Sabre\DAV\Locks\LockInfo;
use Sabre\DAV\PropFind;
+use Sabre\DAV\Server;
use Sabre\DAV\ServerPlugin;
use Sabre\DAV\Xml\Property\LockDiscovery;
use Sabre\DAV\Xml\Property\SupportedLock;
@@ -29,11 +31,11 @@ use Sabre\HTTP\ResponseInterface;
* @package OCA\DAV\Connector\Sabre
*/
class FakeLockerPlugin extends ServerPlugin {
- /** @var \Sabre\DAV\Server */
+ /** @var Server */
private $server;
/** {@inheritDoc} */
- public function initialize(\Sabre\DAV\Server $server) {
+ public function initialize(Server $server) {
$this->server = $server;
$this->server->on('method:LOCK', [$this, 'fakeLockProvider'], 1);
$this->server->on('method:UNLOCK', [$this, 'fakeUnlockProvider'], 1);
@@ -111,7 +113,7 @@ class FakeLockerPlugin extends ServerPlugin {
$lockInfo = new LockInfo();
$lockInfo->token = md5($request->getPath());
$lockInfo->uri = $request->getPath();
- $lockInfo->depth = \Sabre\DAV\Server::DEPTH_INFINITY;
+ $lockInfo->depth = Server::DEPTH_INFINITY;
$lockInfo->timeout = 1800;
$body = $this->server->xml->write('{DAV:}prop', [
@@ -119,7 +121,7 @@ class FakeLockerPlugin extends ServerPlugin {
new LockDiscovery([$lockInfo])
]);
- $response->setStatus(200);
+ $response->setStatus(Http::STATUS_OK);
$response->setBody($body);
return false;
@@ -134,7 +136,7 @@ class FakeLockerPlugin extends ServerPlugin {
*/
public function fakeUnlockProvider(RequestInterface $request,
ResponseInterface $response) {
- $response->setStatus(204);
+ $response->setStatus(Http::STATUS_NO_CONTENT);
$response->setHeader('Content-Length', '0');
return false;
}
diff --git a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
index c44dcc0d2da..9e625ce3184 100644
--- a/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesReportPlugin.php
@@ -10,6 +10,7 @@ namespace OCA\DAV\Connector\Sabre;
use OC\Files\View;
use OCA\Circles\Api\v1\Circles;
use OCP\App\IAppManager;
+use OCP\AppFramework\Http;
use OCP\Files\Folder;
use OCP\Files\Node as INode;
use OCP\IGroupManager;
@@ -183,7 +184,7 @@ class FilesReportPlugin 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);
diff --git a/apps/dav/lib/DAV/Sharing/Plugin.php b/apps/dav/lib/DAV/Sharing/Plugin.php
index cef8dc0b689..03e63813bab 100644
--- a/apps/dav/lib/DAV/Sharing/Plugin.php
+++ b/apps/dav/lib/DAV/Sharing/Plugin.php
@@ -12,6 +12,7 @@ use OCA\DAV\CalDAV\CalendarHome;
use OCA\DAV\Connector\Sabre\Auth;
use OCA\DAV\DAV\Sharing\Xml\Invite;
use OCA\DAV\DAV\Sharing\Xml\ShareRequest;
+use OCP\AppFramework\Http;
use OCP\IConfig;
use OCP\IRequest;
use Sabre\DAV\Exception\NotFound;
@@ -157,7 +158,7 @@ class Plugin extends ServerPlugin {
$node->updateShares($message->set, $message->remove);
- $response->setStatus(200);
+ $response->setStatus(Http::STATUS_OK);
// Adding this because sending a response body may cause issues,
// and I wanted some type of indicator the response was handled.
$response->setHeader('X-Sabre-Status', 'everything-went-well');
diff --git a/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php b/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php
index 36b08cd940c..be5831feee3 100644
--- a/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php
+++ b/apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php
@@ -5,6 +5,7 @@
*/
namespace OCA\DAV\Provisioning\Apple;
+use OCP\AppFramework\Http;
use OCP\IL10N;
use OCP\IRequest;
use OCP\IURLGenerator;
@@ -66,7 +67,7 @@ class AppleProvisioningPlugin extends ServerPlugin {
$useSSL = ($serverProtocol === 'https');
if (!$useSSL) {
- $response->setStatus(200);
+ $response->setStatus(Http::STATUS_OK);
$response->setHeader('Content-Type', 'text/plain; charset=utf-8');
$response->setBody($this->l10n->t('Your %s needs to be configured to use HTTPS in order to use CalDAV and CardDAV with iOS/macOS.', [$this->themingDefaults->getName()]));
@@ -75,11 +76,7 @@ class AppleProvisioningPlugin extends ServerPlugin {
$absoluteURL = $this->urlGenerator->getBaseUrl();
$parsedUrl = parse_url($absoluteURL);
- if (isset($parsedUrl['port'])) {
- $serverPort = $parsedUrl['port'];
- } else {
- $serverPort = 443;
- }
+ $serverPort = $parsedUrl['port'] ?? 443;
$server_url = $parsedUrl['host'];
$description = $this->themingDefaults->getName();
@@ -128,7 +125,7 @@ class AppleProvisioningPlugin extends ServerPlugin {
]
));
- $response->setStatus(200);
+ $response->setStatus(Http::STATUS_OK);
$response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
$response->setHeader('Content-Type', 'application/xml; charset=utf-8');
$response->setBody($body);
diff --git a/apps/dav/lib/SystemTag/SystemTagPlugin.php b/apps/dav/lib/SystemTag/SystemTagPlugin.php
index e66be78c1a1..8305944cb0b 100644
--- a/apps/dav/lib/SystemTag/SystemTagPlugin.php
+++ b/apps/dav/lib/SystemTag/SystemTagPlugin.php
@@ -10,6 +10,7 @@ namespace OCA\DAV\SystemTag;
use OCA\DAV\Connector\Sabre\Directory;
use OCA\DAV\Connector\Sabre\FilesPlugin;
use OCA\DAV\Connector\Sabre\Node;
+use OCP\AppFramework\Http;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserSession;
@@ -127,7 +128,7 @@ class SystemTagPlugin extends \Sabre\DAV\ServerPlugin {
$response->setHeader('Content-Location', $url . $tag->getId());
// created
- $response->setStatus(201);
+ $response->setStatus(Http::STATUS_CREATED);
return false;
}
}
@@ -209,7 +210,7 @@ class SystemTagPlugin extends \Sabre\DAV\ServerPlugin {
return;
}
- if (!($node instanceof SystemTagNode) && !($node instanceof SystemTagMappingNode) && !($node instanceof SystemTagObjectType)) {
+ if (!$node instanceof SystemTagNode && !$node instanceof SystemTagMappingNode && !$node instanceof SystemTagObjectType) {
return;
}
@@ -372,18 +373,18 @@ class SystemTagPlugin extends \Sabre\DAV\ServerPlugin {
*/
public function handleUpdateProperties($path, PropPatch $propPatch) {
$node = $this->server->tree->getNodeForPath($path);
- if (!($node instanceof SystemTagNode) && !($node instanceof SystemTagObjectType)) {
+ if (!$node instanceof SystemTagNode && !$node instanceof SystemTagObjectType) {
return;
}
$propPatch->handle([self::OBJECTIDS_PROPERTYNAME], function ($props) use ($node) {
- if (!($node instanceof SystemTagObjectType)) {
+ if (!$node instanceof SystemTagObjectType) {
return false;
}
if (isset($props[self::OBJECTIDS_PROPERTYNAME])) {
$propValue = $props[self::OBJECTIDS_PROPERTYNAME];
- if (!($propValue instanceof SystemTagsObjectList) || count($propValue->getObjects()) === 0) {
+ if (!$propValue instanceof SystemTagsObjectList || count($propValue->getObjects()) === 0) {
throw new BadRequest('Invalid object-ids property');
}
@@ -413,7 +414,7 @@ class SystemTagPlugin extends \Sabre\DAV\ServerPlugin {
self::REFERENCE_FILEID_PROPERTYNAME,
self::COLOR_PROPERTYNAME,
], function ($props) use ($node) {
- if (!($node instanceof SystemTagNode)) {
+ if (!$node instanceof SystemTagNode) {
return false;
}
diff --git a/apps/dav/lib/Upload/ChunkingPlugin.php b/apps/dav/lib/Upload/ChunkingPlugin.php
index cf4d65168cc..8cc8f7d6c61 100644
--- a/apps/dav/lib/Upload/ChunkingPlugin.php
+++ b/apps/dav/lib/Upload/ChunkingPlugin.php
@@ -9,6 +9,7 @@ namespace OCA\DAV\Upload;
use OCA\DAV\Connector\Sabre\Directory;
use OCA\DAV\Connector\Sabre\Exception\Forbidden;
+use OCP\AppFramework\Http;
use Sabre\DAV\Exception\BadRequest;
use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\INode;
@@ -89,7 +90,7 @@ class ChunkingPlugin extends ServerPlugin {
$response = $this->server->httpResponse;
$response->setHeader('Content-Length', '0');
- $response->setStatus($fileExists ? 204 : 201);
+ $response->setStatus($fileExists ? Http::STATUS_NO_CONTENT : Http::STATUS_CREATED);
return false;
}
diff --git a/apps/dav/lib/Upload/ChunkingV2Plugin.php b/apps/dav/lib/Upload/ChunkingV2Plugin.php
index 846b4ea42ba..07452dc0593 100644
--- a/apps/dav/lib/Upload/ChunkingV2Plugin.php
+++ b/apps/dav/lib/Upload/ChunkingV2Plugin.php
@@ -18,6 +18,7 @@ use OC\Memcache\Redis;
use OC_Hook;
use OCA\DAV\Connector\Sabre\Directory;
use OCA\DAV\Connector\Sabre\File;
+use OCP\AppFramework\Http;
use OCP\Files\IMimeTypeDetector;
use OCP\Files\IRootFolder;
use OCP\Files\ObjectStore\IObjectStoreMultiPartUpload;
@@ -124,7 +125,7 @@ class ChunkingV2Plugin extends ServerPlugin {
self::UPLOAD_TARGET_ID => $targetFile->getId(),
], 86400);
- $response->setStatus(201);
+ $response->setStatus(Http::STATUS_CREATED);
return true;
}
@@ -235,7 +236,7 @@ class ChunkingV2Plugin extends ServerPlugin {
$response = $this->server->httpResponse;
$response->setHeader('Content-Type', 'application/xml; charset=utf-8');
$response->setHeader('Content-Length', '0');
- $response->setStatus($destinationExists ? 204 : 201);
+ $response->setStatus($destinationExists ? Http::STATUS_NO_CONTENT : Http::STATUS_CREATED);
return false;
}