]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(comments): Use provided offset in best effort when loading comments 40507/head
authorJoas Schilling <coding@schilljs.com>
Mon, 18 Sep 2023 18:09:32 +0000 (20:09 +0200)
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>
Tue, 19 Sep 2023 14:06:12 +0000 (14:06 +0000)
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>
lib/private/Comments/Manager.php

index b5bfbc43100fb5a44bde2855a5ca55545ae750e6..e6a174f59ad181a7a1c2851fdc2cbce9dce63133 100644 (file)
@@ -548,6 +548,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();