]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(comments): Use provided offset in best effort when loading comments 40506/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 13:47:51 +0000 (13:47 +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 117318fb2782fe361d953e6b68dec6e1365fb096..7847badd74b4bf4e0e560092d300d331fc4ae870 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();