mirror of
https://github.com/nextcloud/server.git
synced 2026-04-29 18:11:41 -04:00
Update ICommentsManager with reaction methods
Fix psalm errors Reorder methods and remove return null Use best pattern on docblock Goals: update https://github.com/ChristophWurst/nextcloud_composer/ with reaction methods. The script https://github.com/ChristophWurst/nextcloud_composer/blob/master/build.sh only get lib/public classes Signed-off-by: Vitor Mattos <vitor@php.rio>
This commit is contained in:
parent
d635d58d19
commit
8ec7c5c8ae
3 changed files with 109 additions and 36 deletions
|
|
@ -969,7 +969,7 @@ class Manager implements ICommentsManager {
|
|||
* Throws PreConditionNotMetException when the system haven't the minimum requirements to
|
||||
* use reactions
|
||||
*
|
||||
* @param integer $parentId
|
||||
* @param int $parentId
|
||||
* @param string $actorType
|
||||
* @param string $actorId
|
||||
* @param string $reaction
|
||||
|
|
@ -997,14 +997,46 @@ class Manager implements ICommentsManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieve all reactions with specific reaction of a message
|
||||
* Retrieve all reactions of a message
|
||||
*
|
||||
* @param integer $parentId
|
||||
* @param string $reaction
|
||||
* Throws PreConditionNotMetException when the system haven't the minimum requirements to
|
||||
* use reactions
|
||||
*
|
||||
* @param int $parentId
|
||||
* @return IComment[]
|
||||
* @throws PreConditionNotMetException
|
||||
* @since 24.0.0
|
||||
*/
|
||||
public function retrieveAllReactionsWithSpecificReaction(int $parentId, string $reaction): ?array {
|
||||
public function retrieveAllReactions(int $parentId): array {
|
||||
$this->throwIfNotSupportReactions();
|
||||
$qb = $this->dbConn->getQueryBuilder();
|
||||
$result = $qb
|
||||
->select('message_id')
|
||||
->from('reactions')
|
||||
->where($qb->expr()->eq('parent_id', $qb->createNamedParameter($parentId)))
|
||||
->executeQuery();
|
||||
|
||||
$commentIds = [];
|
||||
while ($data = $result->fetch()) {
|
||||
$commentIds[] = $data['message_id'];
|
||||
}
|
||||
|
||||
return $this->getCommentsById($commentIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all reactions with specific reaction of a message
|
||||
*
|
||||
* Throws PreConditionNotMetException when the system haven't the minimum requirements to
|
||||
* use reactions
|
||||
*
|
||||
* @param int $parentId
|
||||
* @param string $reaction
|
||||
* @return IComment[]
|
||||
* @throws PreConditionNotMetException
|
||||
* @since 24.0.0
|
||||
*/
|
||||
public function retrieveAllReactionsWithSpecificReaction(int $parentId, string $reaction): array {
|
||||
$this->throwIfNotSupportReactions();
|
||||
$qb = $this->dbConn->getQueryBuilder();
|
||||
$result = $qb
|
||||
|
|
@ -1029,7 +1061,7 @@ class Manager implements ICommentsManager {
|
|||
/**
|
||||
* Support reactions
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
* @since 24.0.0
|
||||
*/
|
||||
public function supportReactions(): bool {
|
||||
|
|
@ -1046,39 +1078,10 @@ class Manager implements ICommentsManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve all reactions of a message
|
||||
*
|
||||
* Throws PreConditionNotMetException when the system haven't the minimum requirements to
|
||||
* use reactions
|
||||
*
|
||||
* @param integer $parentId
|
||||
* @param string $reaction
|
||||
* @throws PreConditionNotMetException
|
||||
* @return IComment[]
|
||||
* @since 24.0.0
|
||||
*/
|
||||
public function retrieveAllReactions(int $parentId): array {
|
||||
$this->throwIfNotSupportReactions();
|
||||
$qb = $this->dbConn->getQueryBuilder();
|
||||
$result = $qb
|
||||
->select('message_id')
|
||||
->from('reactions')
|
||||
->where($qb->expr()->eq('parent_id', $qb->createNamedParameter($parentId)))
|
||||
->executeQuery();
|
||||
|
||||
$commentIds = [];
|
||||
while ($data = $result->fetch()) {
|
||||
$commentIds[] = $data['message_id'];
|
||||
}
|
||||
|
||||
return $this->getCommentsById($commentIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all comments on list
|
||||
*
|
||||
* @param integer[] $commentIds
|
||||
* @param int[] $commentIds
|
||||
* @return IComment[]
|
||||
* @since 24.0.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
namespace OCP\Comments;
|
||||
|
||||
use OCP\IUser;
|
||||
use OCP\PreConditionNotMetException;
|
||||
|
||||
/**
|
||||
* Interface ICommentsManager
|
||||
|
|
@ -300,6 +301,58 @@ interface ICommentsManager {
|
|||
*/
|
||||
public function delete($id);
|
||||
|
||||
/**
|
||||
* Get comment related with user reaction
|
||||
*
|
||||
* Throws PreConditionNotMetException when the system haven't the minimum requirements to
|
||||
* use reactions
|
||||
*
|
||||
* @param int $parentId
|
||||
* @param string $actorType
|
||||
* @param string $actorId
|
||||
* @param string $reaction
|
||||
* @return IComment
|
||||
* @throws NotFoundException
|
||||
* @throws PreConditionNotMetException
|
||||
* @since 24.0.0
|
||||
*/
|
||||
public function getReactionComment(int $parentId, string $actorType, string $actorId, string $reaction): IComment;
|
||||
|
||||
/**
|
||||
* Retrieve all reactions of a message
|
||||
*
|
||||
* Throws PreConditionNotMetException when the system haven't the minimum requirements to
|
||||
* use reactions
|
||||
*
|
||||
* @param int $parentId
|
||||
* @return IComment[]
|
||||
* @throws PreConditionNotMetException
|
||||
* @since 24.0.0
|
||||
*/
|
||||
public function retrieveAllReactions(int $parentId): array;
|
||||
|
||||
/**
|
||||
* Retrieve all reactions with specific reaction of a message
|
||||
*
|
||||
* Throws PreConditionNotMetException when the system haven't the minimum requirements to
|
||||
* use reactions
|
||||
*
|
||||
* @param int $parentId
|
||||
* @param string $reaction
|
||||
* @return IComment[]
|
||||
* @throws PreConditionNotMetException
|
||||
* @since 24.0.0
|
||||
*/
|
||||
public function retrieveAllReactionsWithSpecificReaction(int $parentId, string $reaction): array;
|
||||
|
||||
/**
|
||||
* Support reactions
|
||||
*
|
||||
* @return bool
|
||||
* @since 24.0.0
|
||||
*/
|
||||
public function supportReactions(): bool;
|
||||
|
||||
/**
|
||||
* saves the comment permanently
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Test\Comments;
|
||||
|
||||
use OC\Comments\Comment;
|
||||
use OCP\Comments\IComment;
|
||||
use OCP\Comments\ICommentsManager;
|
||||
use OCP\IUser;
|
||||
|
|
@ -61,6 +62,22 @@ class FakeManager implements ICommentsManager {
|
|||
public function delete($id) {
|
||||
}
|
||||
|
||||
public function getReactionComment(int $parentId, string $actorType, string $actorId, string $reaction): IComment {
|
||||
return new Comment();
|
||||
}
|
||||
|
||||
public function retrieveAllReactions(int $parentId): array {
|
||||
return [];
|
||||
}
|
||||
|
||||
public function retrieveAllReactionsWithSpecificReaction(int $parentId, string $reaction): array {
|
||||
return [];
|
||||
}
|
||||
|
||||
public function supportReactions(): bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function save(IComment $comment) {
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue