diff options
Diffstat (limited to 'apps/dav/lib/comments')
-rw-r--r-- | apps/dav/lib/comments/entitycollection.php | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/apps/dav/lib/comments/entitycollection.php b/apps/dav/lib/comments/entitycollection.php index 0cc5526c529..a55a18c00c0 100644 --- a/apps/dav/lib/comments/entitycollection.php +++ b/apps/dav/lib/comments/entitycollection.php @@ -25,7 +25,9 @@ use OCP\Comments\ICommentsManager; use OCP\Files\Folder; use OCP\ILogger; use OCP\IUserManager; +use OCP\IUserSession; use Sabre\DAV\Exception\NotFound; +use Sabre\DAV\PropPatch; /** * Class EntityCollection @@ -35,7 +37,9 @@ use Sabre\DAV\Exception\NotFound; * * @package OCA\DAV\Comments */ -class EntityCollection extends RootCollection { +class EntityCollection extends RootCollection implements \Sabre\DAV\IProperties { + const PROPERTY_NAME_READ_MARKER = '{http://owncloud.org/ns}readMarker'; + /** @var Folder */ protected $fileRoot; @@ -159,5 +163,37 @@ class EntityCollection extends RootCollection { return false; } } + + /** + * Sets the read marker to the specified date for the logged in user + * + * @param \DateTime $value + * @return bool + */ + public function setReadMarker($value) { + $dateTime = new \DateTime($value); + $user = $this->userSession->getUser(); + $this->commentsManager->setReadMark($this->name, $this->id, $dateTime, $user); + return true; + } + + /** + * @inheritdoc + */ + function propPatch(PropPatch $propPatch) { + $propPatch->handle(self::PROPERTY_NAME_READ_MARKER, [$this, 'setReadMarker']); + } + + /** + * @inheritdoc + */ + function getProperties($properties) { + $marker = null; + $user = $this->userSession->getUser(); + if(!is_null($user)) { + $marker = $this->commentsManager->getReadMark($this->name, $this->id, $user); + } + return [self::PROPERTY_NAME_READ_MARKER => $marker]; + } } |