Supporting all parameters

This commit is contained in:
Michael 2021-05-19 22:33:40 +00:00
parent 3d65ef3af2
commit 66ad777f4b

View 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);
}
}