aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Comments
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-09-18 20:09:32 +0200
committerJoas Schilling <coding@schilljs.com>2023-09-18 20:09:32 +0200
commit4d2217073acf6ed844bd006c102e403e7978e813 (patch)
tree8560af41b9572e52903f5466bfebf633447e7885 /lib/private/Comments
parentcf7344082d5cbbf6aa4afcaf46c08a30685e68ce (diff)
downloadnextcloud-server-4d2217073acf6ed844bd006c102e403e7978e813.tar.gz
nextcloud-server-4d2217073acf6ed844bd006c102e403e7978e813.zip
fix(comments): Use provided offset in best effort when loading comments
When we didn't find the "$lastKnownComment" the whole condition was ignored. Now we still use the ID as an offset. This is required as a fall-back for expired messages in Talk and deleted comments in other apps. Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Comments')
-rw-r--r--lib/private/Comments/Manager.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php
index af4fda277d6..725febef85d 100644
--- a/lib/private/Comments/Manager.php
+++ b/lib/private/Comments/Manager.php
@@ -501,6 +501,22 @@ class Manager implements ICommentsManager {
)
);
}
+ } elseif ($lastKnownCommentId > 0) {
+ // We didn't find the "$lastKnownComment" but we still use the ID as an offset.
+ // This is required as a fall-back for expired messages in talk and deleted comments in other apps.
+ if ($sortDirection === 'desc') {
+ if ($includeLastKnown) {
+ $query->andWhere($query->expr()->lte('id', $query->createNamedParameter($lastKnownCommentId)));
+ } else {
+ $query->andWhere($query->expr()->lt('id', $query->createNamedParameter($lastKnownCommentId)));
+ }
+ } else {
+ if ($includeLastKnown) {
+ $query->andWhere($query->expr()->gte('id', $query->createNamedParameter($lastKnownCommentId)));
+ } else {
+ $query->andWhere($query->expr()->gt('id', $query->createNamedParameter($lastKnownCommentId)));
+ }
+ }
}
$resultStatement = $query->execute();