Add common relationship methods to Model\ContactRelation

- Introduce DBA::mergeConditions method
- Replace GContact relationship method contents with Model\ContactRelation method calls
This commit is contained in:
Hypolite Petovan 2020-07-29 11:30:54 -04:00
parent a6a23802b7
commit 24a82110fd
5 changed files with 425 additions and 117 deletions

View file

@ -143,7 +143,7 @@ abstract class ContactEndpoint extends BaseApi
$previous_cursor = 0;
$total_count = 0;
if (!$hide_friends) {
$condition = DBA::collapseCondition([
$condition = [
'rel' => $rel,
'uid' => $uid,
'self' => false,
@ -151,17 +151,15 @@ abstract class ContactEndpoint extends BaseApi
'hidden' => false,
'archive' => false,
'pending' => false
]);
];
$total_count = DBA::count('contact', $condition);
if ($cursor !== -1) {
if ($cursor > 0) {
$condition[0] .= " AND `id` > ?";
$condition[] = $cursor;
$condition = DBA::mergeConditions($condition, ['`id` > ?', $cursor]);
} else {
$condition[0] .= " AND `id` < ?";
$condition[] = -$cursor;
$condition = DBA::mergeConditions($condition, ['`id` < ?', -$cursor]);
}
}