aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Comments
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2020-10-21 09:08:48 +0200
committerJoas Schilling <coding@schilljs.com>2020-10-21 09:08:48 +0200
commit2cc35cc65d251ac52e1e09fe52381ccbf64eb89f (patch)
treee4d29dd08d96a66902e297483d2ca67d5e508202 /lib/private/Comments
parent2c21adb5a65787b378172adc0257f6d11bbf1428 (diff)
downloadnextcloud-server-2cc35cc65d251ac52e1e09fe52381ccbf64eb89f.tar.gz
nextcloud-server-2cc35cc65d251ac52e1e09fe52381ccbf64eb89f.zip
Include an option to also include the lastKnownCommentId object
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Comments')
-rw-r--r--lib/private/Comments/Manager.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php
index 3c9be9828d1..dc449cc4d4b 100644
--- a/lib/private/Comments/Manager.php
+++ b/lib/private/Comments/Manager.php
@@ -395,6 +395,7 @@ class Manager implements ICommentsManager {
* @param string $sortDirection direction of the comments (`asc` or `desc`)
* @param int $limit optional, number of maximum comments to be returned. if
* set to 0, all comments are returned.
+ * @param bool $includeLastKnown
* @return IComment[]
* @return array
*/
@@ -403,7 +404,8 @@ class Manager implements ICommentsManager {
string $objectId,
int $lastKnownCommentId,
string $sortDirection = 'asc',
- int $limit = 30
+ int $limit = 30,
+ bool $includeLastKnown = false
): array {
$comments = [];
@@ -427,6 +429,7 @@ class Manager implements ICommentsManager {
if ($lastKnownComment instanceof IComment) {
$lastKnownCommentDateTime = $lastKnownComment->getCreationDateTime();
if ($sortDirection === 'desc') {
+ $idComparison = $includeLastKnown ? 'lte' : 'lt';
$query->andWhere(
$query->expr()->orX(
$query->expr()->lt(
@@ -440,11 +443,12 @@ class Manager implements ICommentsManager {
$query->createNamedParameter($lastKnownCommentDateTime, IQueryBuilder::PARAM_DATE),
IQueryBuilder::PARAM_DATE
),
- $query->expr()->lt('id', $query->createNamedParameter($lastKnownCommentId))
+ $query->expr()->$idComparison('id', $query->createNamedParameter($lastKnownCommentId))
)
)
);
} else {
+ $idComparison = $includeLastKnown ? 'gte' : 'gt';
$query->andWhere(
$query->expr()->orX(
$query->expr()->gt(
@@ -458,7 +462,7 @@ class Manager implements ICommentsManager {
$query->createNamedParameter($lastKnownCommentDateTime, IQueryBuilder::PARAM_DATE),
IQueryBuilder::PARAM_DATE
),
- $query->expr()->gt('id', $query->createNamedParameter($lastKnownCommentId))
+ $query->expr()->$idComparison('id', $query->createNamedParameter($lastKnownCommentId))
)
)
);