diff options
author | Joas Schilling <coding@schilljs.com> | 2025-07-10 12:37:49 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2025-07-10 12:58:46 +0200 |
commit | 6600c1ad86cc747522b9af10556d620916806b92 (patch) | |
tree | 92dce4a5c624143d022641922346b67d1c56300e | |
parent | 345a0a07355182851c1616751cb3bd06351def1f (diff) | |
download | nextcloud-server-feat/talk-9679/threads.tar.gz nextcloud-server-feat/talk-9679/threads.zip |
feat(comments): Allow to filter by topmost parent idfeat/talk-9679/threads
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | lib/private/Comments/Manager.php | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php index d959ebcb0a3..047fa361dad 100644 --- a/lib/private/Comments/Manager.php +++ b/lib/private/Comments/Manager.php @@ -364,6 +364,7 @@ class Manager implements ICommentsManager { * @param int $limit optional, number of maximum comments to be returned. if * set to 0, all comments are returned. * @param bool $includeLastKnown + * @param string $topmostParentId Limit the comments to a list of replies and its original root comment * @return list<IComment> */ public function getForObjectSince( @@ -373,6 +374,7 @@ class Manager implements ICommentsManager { string $sortDirection = 'asc', int $limit = 30, bool $includeLastKnown = false, + string $topmostParentId = '', ): array { return $this->getCommentsWithVerbForObjectSinceComment( $objectType, @@ -381,7 +383,8 @@ class Manager implements ICommentsManager { $lastKnownCommentId, $sortDirection, $limit, - $includeLastKnown + $includeLastKnown, + $topmostParentId, ); } @@ -394,6 +397,7 @@ class Manager implements ICommentsManager { * @param int $limit optional, number of maximum comments to be returned. if * set to 0, all comments are returned. * @param bool $includeLastKnown + * @param string $topmostParentId Limit the comments to a list of replies and its original root comment * @return list<IComment> */ public function getCommentsWithVerbForObjectSinceComment( @@ -404,6 +408,7 @@ class Manager implements ICommentsManager { string $sortDirection = 'asc', int $limit = 30, bool $includeLastKnown = false, + string $topmostParentId = '', ): array { $comments = []; @@ -423,6 +428,13 @@ class Manager implements ICommentsManager { $query->andWhere($query->expr()->in('verb', $query->createNamedParameter($verbs, IQueryBuilder::PARAM_STR_ARRAY))); } + if ($topmostParentId !== '') { + $query->andWhere($query->expr()->orX( + $query->expr()->eq('id', $query->createNamedParameter($topmostParentId)), + $query->expr()->eq('topmost_parent_id', $query->createNamedParameter($topmostParentId)), + )); + } + $lastKnownComment = $lastKnownCommentId > 0 ? $this->getLastKnownComment( $objectType, $objectId, |