X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FApi%2FTwitter%2FFriends%2FIds.php;h=736c78fae26033791b5cefc14503531c6b443937;hb=ff5da9bc7138752483bb346b62b550c0496dda1d;hp=dfc5ba4e5f2487c9755b7886a57ff7eb931f387c;hpb=b2042253c45f7925d515d8c6b8fdd4a73c2ee784;p=friendica.git diff --git a/src/Module/Api/Twitter/Friends/Ids.php b/src/Module/Api/Twitter/Friends/Ids.php index dfc5ba4e5f..736c78fae2 100644 --- a/src/Module/Api/Twitter/Friends/Ids.php +++ b/src/Module/Api/Twitter/Friends/Ids.php @@ -1,6 +1,6 @@ ['default' => -1]]); - $stringify_ids = filter_input(INPUT_GET, 'stringify_ids', FILTER_VALIDATE_BOOLEAN, ['options' => ['default' => false]]); - $count = filter_input(INPUT_GET, 'count' , FILTER_VALIDATE_INT, ['options' => [ - 'default' => self::DEFAULT_COUNT, - 'min_range' => 1, - 'max_range' => self::MAX_COUNT, - ]]); - // Friendica-specific - $since_id = filter_input(INPUT_GET, 'since_id' , FILTER_VALIDATE_INT); - $max_id = filter_input(INPUT_GET, 'max_id' , FILTER_VALIDATE_INT); - $min_id = filter_input(INPUT_GET, 'min_id' , FILTER_VALIDATE_INT); - - $cid = BaseApi::getContactIDForSearchterm($screen_name, $profile_url, $contact_id, $uid); - - $params = ['order' => ['cid' => true], 'limit' => $count]; - - $condition = ['relation-cid' => $cid, 'follows' => true]; + $cid = BaseApi::getContactIDForSearchterm($this->getRequestValue($request, 'screen_name', ''), $this->getRequestValue($request, 'profileurl', ''), $this->getRequestValue($request, 'user_id', 0), $uid); + $cursor = $this->getRequestValue($request, 'cursor', -1); + $stringify_ids = $this->getRequestValue($request, 'stringify_ids', false); + $count = $this->getRequestValue($request, 'count', self::DEFAULT_COUNT, 1, self::MAX_COUNT); - $total_count = (int)DBA::count('contact-relation', $condition); - - if (!empty($max_id)) { - $condition = DBA::mergeConditions($condition, ["`cid` < ?", $max_id]); - } - - if (!empty($since_id)) { - $condition = DBA::mergeConditions($condition, ["`cid` > ?", $since_id]); - } - - if (!empty($min_id)) { - $condition = DBA::mergeConditions($condition, ["`cid` > ?", $min_id]); - - $params['order'] = ['cid']; - } - - $ids = []; - - $followers = DBA::select('contact-relation', ['cid'], $condition, $params); - while ($follower = DBA::fetch($followers)) { - self::setBoundaries($follower['cid']); - $ids[] = $follower['cid']; + // Friendica-specific + $since_id = $this->getRequestValue($request, 'since_id', 0, 0); + $max_id = $this->getRequestValue($request, 'max_id', 0, 0); + $min_id = $this->getRequestValue($request, 'min_id', 0, 0); + + if ($cid == Contact::getPublicIdByUserId($uid)) { + $params = ['order' => ['pid' => true], 'limit' => $count]; + + $condition = ['uid' => $uid, 'self' => false, 'rel' => [Contact::SHARING, Contact::FRIEND]]; + + if (!empty($max_id)) { + $condition = DBA::mergeConditions($condition, ["`pid` < ?", $max_id]); + } + + if (!empty($since_id)) { + $condition = DBA::mergeConditions($condition, ["`pid` > ?", $since_id]); + } + + if (!empty($min_id)) { + $condition = DBA::mergeConditions($condition, ["`pid` > ?", $min_id]); + + $params['order'] = ['pid']; + } + + $ids = []; + + foreach (Contact::selectAccountToArray(['pid'], $condition, $params) as $follower) { + self::setBoundaries($follower['pid']); + $ids[] = $follower['pid']; + } + } else { + $params = ['order' => ['cid' => true], 'limit' => $count]; + + $condition = ['relation-cid' => $cid, 'follows' => true]; + + $total_count = (int)DBA::count('contact-relation', $condition); + + if (!empty($max_id)) { + $condition = DBA::mergeConditions($condition, ["`cid` < ?", $max_id]); + } + + if (!empty($since_id)) { + $condition = DBA::mergeConditions($condition, ["`cid` > ?", $since_id]); + } + + if (!empty($min_id)) { + $condition = DBA::mergeConditions($condition, ["`cid` > ?", $min_id]); + + $params['order'] = ['cid']; + } + + $ids = []; + + $followers = DBA::select('contact-relation', ['cid'], $condition, $params); + while ($follower = DBA::fetch($followers)) { + self::setBoundaries($follower['cid']); + $ids[] = $follower['cid']; + } + DBA::close($followers); } - DBA::close($followers); if (!empty($min_id)) { $ids = array_reverse($ids);