-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add note to dav endpoint #12978
Add note to dav endpoint #12978
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 @@ public function initialize(\Sabre\DAV\Server $server) { | |
$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 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node) | |
$propFind->handle(self::MOUNT_TYPE_PROPERTYNAME, function () use ($node) { | ||
return $node->getFileInfo()->getMountPoint()->getMountType(); | ||
}); | ||
|
||
$propFind->handle(self::SHARE_NOTE, function() use ($node, $httpRequest) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar comments as to #14429 I think it would make sense to move this to the share plugin we have. |
||
return $node->getNoteFromShare( | ||
$httpRequest->getRawServerValue('PHP_AUTH_USER') | ||
); | ||
}); | ||
} | ||
|
||
if ($node instanceof \OCA\DAV\Connector\Sabre\Node) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,8 @@ | |
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 { | ||
|
@@ -290,6 +292,35 @@ public function getSharePermissions($user) { | |
return $permissions; | ||
} | ||
|
||
/** | ||
* @param string $user | ||
* @return string | ||
*/ | ||
public function getNoteFromShare($user) { | ||
ChristophWurst marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I doubt this works... The third argument expects a node for sure... but this is a different note that the sharing one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok so it works because the actual function e use int he share amanger is also present. But this will do 💥 at some point. Either we revert this or we fix it. Because this is not really something we can leave around and have do 💥 when we move to more strict typing. Especially since this isn't covered by any tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can fix it by putting an instanceof check against $this beforehand, in line 300. Would be the easiest thing to do, but perhaps not cleanest one. Alternative would be to retrieve always correct Node instance, if possible. There's no straight way from View or FileInfo, and I did not look deeper by now. |
||
foreach ($shares as $share) { | ||
$note = $share->getNote(); | ||
if($share->getShareOwner() !== $user && !empty($note)) { | ||
return $note; | ||
} | ||
} | ||
} | ||
|
||
return ''; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also
share-note
maybe... as justnote
is a bit generic?