]> git.mxchange.org Git - friendica.git/commitdiff
Supporting all parameters
authorMichael <heluecht@pirati.ca>
Wed, 19 May 2021 22:33:40 +0000 (22:33 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 19 May 2021 22:33:40 +0000 (22:33 +0000)
src/Module/Api/Mastodon/Conversation.php

index 03ea737f0760d62a4559598b76be45e6d7c3cfd6..4b6c60e56fbdbec826f3be1ac3871a37eb50cd6e 100644 (file)
@@ -64,7 +64,22 @@ class Conversation extends BaseApi
 
                $params = ['order' => ['id' => true], 'limit' => $request['limit']];
 
-               $convs = DBA::select('conv', ['id'], ['uid' => $uid], $params);
+               $condition = ['uid' => $uid];
+
+               if (!empty($request['max_id'])) {
+                       $condition = DBA::mergeConditions($condition, ["`id` < ?", $request['max_id']]);
+               }
+
+               if (!empty($request['since_id'])) {
+                       $condition = DBA::mergeConditions($condition, ["`id` > ?", $request['since_id']]);
+               }
+
+               if (!empty($request['min_id'])) {
+                       $condition = DBA::mergeConditions($condition, ["`id` > ?", $request['min_id']]);
+                       $params['order'] = ['id'];
+               }
+
+               $convs = DBA::select('conv', ['id'], $condition, $params);
 
                $conversations = [];
 
@@ -72,6 +87,10 @@ class Conversation extends BaseApi
                        $conversations[] = DI::mstdnConversation()->CreateFromConvId($conv['id']);
                }
 
+               if (!empty($request['min_id'])) {
+                       array_reverse($conversations);
+               }
+
                System::jsonExit($conversations);
        }
 }