2015-11-10 19:44:26 +03:00
|
|
|
<?php
|
2016-01-12 17:02:16 +03:00
|
|
|
/**
|
2016-07-21 18:07:57 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2016-05-26 20:56:05 +03:00
|
|
|
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2016-03-01 19:25:15 +03:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
2016-01-12 17:02:16 +03:00
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2016-01-12 17:02:16 +03:00
|
|
|
*
|
|
|
|
*/
|
2019-11-22 22:52:10 +03:00
|
|
|
|
2015-11-10 19:44:26 +03:00
|
|
|
namespace OCP\Comments;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface IComment
|
|
|
|
*
|
2015-12-03 19:20:40 +03:00
|
|
|
* This class represents a comment
|
2015-11-10 19:44:26 +03:00
|
|
|
*
|
|
|
|
* @package OCP\Comments
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
interface IComment {
|
2020-04-10 17:54:27 +03:00
|
|
|
public const MAX_MESSAGE_LENGTH = 1000;
|
2015-11-10 19:44:26 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* returns the ID of the comment
|
|
|
|
*
|
|
|
|
* It may return an empty string, if the comment was not stored.
|
|
|
|
* It is expected that the concrete Comment implementation gives an ID
|
|
|
|
* by itself (e.g. after saving).
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function getId();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sets the ID of the comment and returns itself
|
|
|
|
*
|
|
|
|
* It is only allowed to set the ID only, if the current id is an empty
|
|
|
|
* string (which means it is not stored in a database, storage or whatever
|
|
|
|
* the concrete implementation does), or vice versa. Changing a given ID is
|
|
|
|
* not permitted and must result in an IllegalIDChangeException.
|
|
|
|
*
|
|
|
|
* @param string $id
|
|
|
|
* @return IComment
|
|
|
|
* @throws IllegalIDChangeException
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function setId($id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns the parent ID of the comment
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function getParentId();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sets the parent ID and returns itself
|
|
|
|
* @param string $parentId
|
|
|
|
* @return IComment
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function setParentId($parentId);
|
|
|
|
|
2015-11-24 01:53:55 +03:00
|
|
|
/**
|
|
|
|
* returns the topmost parent ID of the comment
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function getTopmostParentId();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sets the topmost parent ID and returns itself
|
|
|
|
*
|
|
|
|
* @param string $id
|
|
|
|
* @return IComment
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function setTopmostParentId($id);
|
|
|
|
|
2015-11-10 19:44:26 +03:00
|
|
|
/**
|
|
|
|
* returns the number of children
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function getChildrenCount();
|
|
|
|
|
2015-11-24 01:58:22 +03:00
|
|
|
/**
|
|
|
|
* sets the number of children
|
|
|
|
*
|
|
|
|
* @param int $count
|
|
|
|
* @return IComment
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function setChildrenCount($count);
|
|
|
|
|
2015-11-10 19:44:26 +03:00
|
|
|
/**
|
|
|
|
* returns the message of the comment
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function getMessage();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sets the message of the comment and returns itself
|
|
|
|
*
|
2016-02-09 05:14:30 +03:00
|
|
|
* When the given message length exceeds MAX_MESSAGE_LENGTH an
|
|
|
|
* MessageTooLongException shall be thrown.
|
|
|
|
*
|
2015-11-10 19:44:26 +03:00
|
|
|
* @param string $message
|
2019-06-26 11:11:46 +03:00
|
|
|
* @param int $maxLength
|
2015-11-10 19:44:26 +03:00
|
|
|
* @return IComment
|
2016-02-09 05:14:30 +03:00
|
|
|
* @throws MessageTooLongException
|
2019-06-26 11:11:46 +03:00
|
|
|
* @since 9.0.0 - $maxLength added in 16.0.2
|
2015-11-10 19:44:26 +03:00
|
|
|
*/
|
2019-06-26 11:11:46 +03:00
|
|
|
public function setMessage($message, $maxLength = self::MAX_MESSAGE_LENGTH);
|
2015-11-10 19:44:26 +03:00
|
|
|
|
2016-10-14 01:19:31 +03:00
|
|
|
/**
|
|
|
|
* returns an array containing mentions that are included in the comment
|
|
|
|
*
|
|
|
|
* @return array each mention provides a 'type' and an 'id', see example below
|
2016-11-15 20:51:52 +03:00
|
|
|
* @since 11.0.0
|
2016-10-14 01:19:31 +03:00
|
|
|
*
|
|
|
|
* The return array looks like:
|
|
|
|
* [
|
|
|
|
* [
|
|
|
|
* 'type' => 'user',
|
|
|
|
* 'id' => 'citizen4'
|
|
|
|
* ],
|
|
|
|
* [
|
|
|
|
* 'type' => 'group',
|
|
|
|
* 'id' => 'media'
|
|
|
|
* ],
|
|
|
|
* …
|
|
|
|
* ]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function getMentions();
|
|
|
|
|
2015-11-10 19:44:26 +03:00
|
|
|
/**
|
|
|
|
* returns the verb of the comment
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function getVerb();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sets the verb of the comment, e.g. 'comment' or 'like'
|
|
|
|
*
|
|
|
|
* @param string $verb
|
|
|
|
* @return IComment
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function setVerb($verb);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns the actor type
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function getActorType();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns the actor ID
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function getActorId();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sets (overwrites) the actor type and id
|
|
|
|
*
|
2016-02-03 21:28:15 +03:00
|
|
|
* @param string $actorType e.g. 'users'
|
2015-11-10 19:44:26 +03:00
|
|
|
* @param string $actorId e.g. 'zombie234'
|
|
|
|
* @return IComment
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function setActor($actorType, $actorId);
|
|
|
|
|
|
|
|
/**
|
2015-11-23 19:29:44 +03:00
|
|
|
* returns the creation date of the comment.
|
2015-11-10 19:44:26 +03:00
|
|
|
*
|
2015-11-23 19:29:44 +03:00
|
|
|
* If not explicitly set, it shall default to the time of initialization.
|
2015-11-10 19:44:26 +03:00
|
|
|
*
|
|
|
|
* @return \DateTime
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
2015-11-23 19:29:44 +03:00
|
|
|
public function getCreationDateTime();
|
2015-11-10 19:44:26 +03:00
|
|
|
|
|
|
|
/**
|
2015-11-23 19:29:44 +03:00
|
|
|
* sets the creation date of the comment and returns itself
|
2015-11-10 19:44:26 +03:00
|
|
|
*
|
2015-11-24 01:58:22 +03:00
|
|
|
* @param \DateTime $dateTime
|
2015-11-10 19:44:26 +03:00
|
|
|
* @return IComment
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
2015-11-24 01:58:22 +03:00
|
|
|
public function setCreationDateTime(\DateTime $dateTime);
|
2015-11-10 19:44:26 +03:00
|
|
|
|
|
|
|
/**
|
2015-11-24 01:58:22 +03:00
|
|
|
* returns the date of the most recent child
|
2015-11-10 19:44:26 +03:00
|
|
|
*
|
2015-11-24 01:58:22 +03:00
|
|
|
* @return \DateTime
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function getLatestChildDateTime();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sets the date of the most recent child
|
|
|
|
*
|
|
|
|
* @param \DateTime $dateTime
|
|
|
|
* @return IComment
|
2015-11-10 19:44:26 +03:00
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
2015-11-24 01:58:22 +03:00
|
|
|
public function setLatestChildDateTime(\DateTime $dateTime);
|
2015-11-10 19:44:26 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* returns the object type the comment is attached to
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function getObjectType();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* returns the object id the comment is attached to
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function getObjectId();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sets (overwrites) the object of the comment
|
|
|
|
*
|
2016-02-03 21:28:15 +03:00
|
|
|
* @param string $objectType e.g. 'files'
|
2015-11-10 19:44:26 +03:00
|
|
|
* @param string $objectId e.g. '16435'
|
|
|
|
* @return IComment
|
|
|
|
* @since 9.0.0
|
|
|
|
*/
|
|
|
|
public function setObject($objectType, $objectId);
|
|
|
|
|
2020-03-11 14:11:01 +03:00
|
|
|
/**
|
|
|
|
* returns the reference id of the comment
|
|
|
|
*
|
|
|
|
* @return string|null
|
|
|
|
* @since 19.0.0
|
|
|
|
*/
|
|
|
|
public function getReferenceId(): ?string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* sets (overwrites) the reference id of the comment
|
|
|
|
*
|
|
|
|
* @param string|null $referenceId e.g. sha256 hash sum
|
|
|
|
* @return IComment
|
|
|
|
* @since 19.0.0
|
|
|
|
*/
|
|
|
|
public function setReferenceId(?string $referenceId): IComment;
|
2015-11-10 19:44:26 +03:00
|
|
|
}
|