diff options
author | Vitor Mattos <vitor@php.rio> | 2022-01-27 13:07:48 -0300 |
---|---|---|
committer | Vitor Mattos <vitor@php.rio> | 2022-02-03 12:52:18 -0300 |
commit | 8ec7c5c8ae5432c2ca2e738032d7d1118840c840 (patch) | |
tree | 6a2f15d4a77fe1ff09d6f42f3bbb1f38055f055f /lib/private/Comments | |
parent | d635d58d19d5ab65c0be754fc32fce99672c249f (diff) | |
download | nextcloud-server-8ec7c5c8ae5432c2ca2e738032d7d1118840c840.tar.gz nextcloud-server-8ec7c5c8ae5432c2ca2e738032d7d1118840c840.zip |
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>
Diffstat (limited to 'lib/private/Comments')
-rw-r--r-- | lib/private/Comments/Manager.php | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php index 554a2485965..7c312b18f7d 100644 --- a/lib/private/Comments/Manager.php +++ b/lib/private/Comments/Manager.php @@ -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 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 { + $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 * - * @param integer $parentId + * 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 { + 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 { @@ -1047,38 +1079,9 @@ 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 */ |