summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2019-03-04 12:58:09 +0100
committerGitHub <noreply@github.com>2019-03-04 12:58:09 +0100
commitdaee222534f3850e7689066e5391a7f3a9b9d452 (patch)
tree0585fc17badf4759518b9f747859ded2e0aff7e4 /apps/dav
parent814bf0de20b05ef44d4558d49cc3dc655da1c58d (diff)
parentaee348c5f561d1166257d060f8153811f41c5d54 (diff)
downloadnextcloud-server-daee222534f3850e7689066e5391a7f3a9b9d452.tar.gz
nextcloud-server-daee222534f3850e7689066e5391a7f3a9b9d452.zip
Merge pull request #12978 from tobiasKaminsky/noteOnDav
Add note to dav endpoint
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/Connector/Sabre/FilesPlugin.php8
-rw-r--r--apps/dav/lib/Connector/Sabre/Node.php31
2 files changed, 39 insertions, 0 deletions
diff --git a/apps/dav/lib/Connector/Sabre/FilesPlugin.php b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
index f53f13c5687..99317f2bc1c 100644
--- a/apps/dav/lib/Connector/Sabre/FilesPlugin.php
+++ b/apps/dav/lib/Connector/Sabre/FilesPlugin.php
@@ -70,6 +70,7 @@ class FilesPlugin extends ServerPlugin {
const HAS_PREVIEW_PROPERTYNAME = '{http://nextcloud.org/ns}has-preview';
const MOUNT_TYPE_PROPERTYNAME = '{http://nextcloud.org/ns}mount-type';
const IS_ENCRYPTED_PROPERTYNAME = '{http://nextcloud.org/ns}is-encrypted';
+ const SHARE_NOTE = '{http://nextcloud.org/ns}note';
/**
* Reference to main server object
@@ -161,6 +162,7 @@ class FilesPlugin extends ServerPlugin {
$server->protectedProperties[] = self::HAS_PREVIEW_PROPERTYNAME;
$server->protectedProperties[] = self::MOUNT_TYPE_PROPERTYNAME;
$server->protectedProperties[] = self::IS_ENCRYPTED_PROPERTYNAME;
+ $server->protectedProperties[] = self::SHARE_NOTE;
// normally these cannot be changed (RFC4918), but we want them modifiable through PROPPATCH
$allowedProperties = ['{DAV:}getetag'];
@@ -359,6 +361,12 @@ class FilesPlugin extends ServerPlugin {
$propFind->handle(self::MOUNT_TYPE_PROPERTYNAME, function () use ($node) {
return $node->getFileInfo()->getMountPoint()->getMountType();
});
+
+ $propFind->handle(self::SHARE_NOTE, function() use ($node, $httpRequest) {
+ return $node->getNoteFromShare(
+ $httpRequest->getRawServerValue('PHP_AUTH_USER')
+ );
+ });
}
if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php
index 38d0ff57fb2..32ba6c53a0c 100644
--- a/apps/dav/lib/Connector/Sabre/Node.php
+++ b/apps/dav/lib/Connector/Sabre/Node.php
@@ -41,6 +41,8 @@ use OCP\Files\FileInfo;
use OCP\Files\StorageNotAvailableException;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
+use OCP\Share;
+use OCP\Share\IShare;
abstract class Node implements \Sabre\DAV\INode {
@@ -291,6 +293,35 @@ abstract class Node implements \Sabre\DAV\INode {
}
/**
+ * @param string $user
+ * @return string
+ */
+ public function getNoteFromShare($user) {
+ if ($user === null) {
+ return '';
+ }
+
+ $types = [
+ Share::SHARE_TYPE_USER,
+ Share::SHARE_TYPE_GROUP,
+ Share::SHARE_TYPE_CIRCLE,
+ Share::SHARE_TYPE_ROOM
+ ];
+
+ foreach ($types as $shareType) {
+ $shares = $this->shareManager->getSharedWith($user, $shareType, $this, -1);
+ foreach ($shares as $share) {
+ $note = $share->getNote();
+ if($share->getShareOwner() !== $user && !empty($note)) {
+ return $note;
+ }
+ }
+ }
+
+ return '';
+ }
+
+ /**
* @return string
*/
public function getDavPermissions() {