From 8e8ec9d2d21842c8280e02c310b357be3a5b3fb0 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 16 Jan 2022 18:40:18 +0000 Subject: [PATCH] Simplified contact id handling --- src/Module/Api/Twitter/Followers/Ids.php | 6 +----- src/Module/Api/Twitter/Followers/Lists.php | 6 +----- src/Module/Api/Twitter/Friends/Ids.php | 6 +----- src/Module/Api/Twitter/Friends/Lists.php | 6 +----- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/Module/Api/Twitter/Followers/Ids.php b/src/Module/Api/Twitter/Followers/Ids.php index d03b547ac..df7120ab6 100644 --- a/src/Module/Api/Twitter/Followers/Ids.php +++ b/src/Module/Api/Twitter/Followers/Ids.php @@ -37,9 +37,7 @@ class Ids extends ContactEndpoint $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id - $contact_id = $this->getRequestValue($request, 'user_id', 0); - $screen_name = $this->getRequestValue($request, 'screen_name', ''); - $profile_url = $this->getRequestValue($request, 'profile_url', ''); + $cid = BaseApi::getContactIDForSearchterm($request['screen_name'] ?? '', $request['profileurl'] ?? '', $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); @@ -49,8 +47,6 @@ class Ids extends ContactEndpoint $max_id = $this->getRequestValue($request, 'max_id', 0, 0); $min_id = $this->getRequestValue($request, 'min_id', 0, 0); - $cid = BaseApi::getContactIDForSearchterm($screen_name, $profile_url, $contact_id, $uid); - $params = ['order' => ['relation-cid' => true], 'limit' => $count]; $condition = ['cid' => $cid, 'follows' => true]; diff --git a/src/Module/Api/Twitter/Followers/Lists.php b/src/Module/Api/Twitter/Followers/Lists.php index 0aca285a1..0e9a2aa82 100644 --- a/src/Module/Api/Twitter/Followers/Lists.php +++ b/src/Module/Api/Twitter/Followers/Lists.php @@ -37,9 +37,7 @@ class Lists extends ContactEndpoint $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id - $contact_id = $this->getRequestValue($request, 'user_id', 0); - $screen_name = $this->getRequestValue($request, 'screen_name', ''); - $profile_url = $this->getRequestValue($request, 'profile_url', ''); + $cid = BaseApi::getContactIDForSearchterm($request['screen_name'] ?? '', $request['profileurl'] ?? '', $request['user_id'] ?? 0, $uid); $cursor = $this->getRequestValue($request, 'cursor', -1); $skip_status = $this->getRequestValue($request, 'skip_status', false); $include_user_entities = $this->getRequestValue($request, 'include_user_entities', false); @@ -50,8 +48,6 @@ class Lists extends ContactEndpoint $max_id = $this->getRequestValue($request, 'max_id', 0, 0); $min_id = $this->getRequestValue($request, 'min_id', 0, 0); - $cid = BaseApi::getContactIDForSearchterm($screen_name, $profile_url, $contact_id, $uid); - $params = ['order' => ['relation-cid' => true], 'limit' => $count]; $condition = ['cid' => $cid, 'follows' => true]; diff --git a/src/Module/Api/Twitter/Friends/Ids.php b/src/Module/Api/Twitter/Friends/Ids.php index c874432e1..b5b571a9f 100644 --- a/src/Module/Api/Twitter/Friends/Ids.php +++ b/src/Module/Api/Twitter/Friends/Ids.php @@ -37,9 +37,7 @@ class Ids extends ContactEndpoint $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id - $contact_id = $this->getRequestValue($request, 'user_id', 0); - $screen_name = $this->getRequestValue($request, 'screen_name', ''); - $profile_url = $this->getRequestValue($request, 'profile_url', ''); + $cid = BaseApi::getContactIDForSearchterm($request['screen_name'] ?? '', $request['profileurl'] ?? '', $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); @@ -49,8 +47,6 @@ class Ids extends ContactEndpoint $max_id = $this->getRequestValue($request, 'max_id', 0, 0); $min_id = $this->getRequestValue($request, 'min_id', 0, 0); - $cid = BaseApi::getContactIDForSearchterm($screen_name, $profile_url, $contact_id, $uid); - $params = ['order' => ['cid' => true], 'limit' => $count]; $condition = ['relation-cid' => $cid, 'follows' => true]; diff --git a/src/Module/Api/Twitter/Friends/Lists.php b/src/Module/Api/Twitter/Friends/Lists.php index 65dcec8ec..750ba6db6 100644 --- a/src/Module/Api/Twitter/Friends/Lists.php +++ b/src/Module/Api/Twitter/Friends/Lists.php @@ -37,9 +37,7 @@ class Lists extends ContactEndpoint $uid = BaseApi::getCurrentUserID(); // Expected value for user_id parameter: public/user contact id - $contact_id = $this->getRequestValue($request, 'user_id', 0); - $screen_name = $this->getRequestValue($request, 'screen_name', ''); - $profile_url = $this->getRequestValue($request, 'profile_url', ''); + $cid = BaseApi::getContactIDForSearchterm($request['screen_name'] ?? '', $request['profileurl'] ?? '', $request['user_id'] ?? 0, $uid); $cursor = $this->getRequestValue($request, 'cursor', -1); $skip_status = $this->getRequestValue($request, 'skip_status', false); $include_user_entities = $this->getRequestValue($request, 'include_user_entities', false); @@ -50,8 +48,6 @@ class Lists extends ContactEndpoint $max_id = $this->getRequestValue($request, 'max_id', 0, 0); $min_id = $this->getRequestValue($request, 'min_id', 0, 0); - $cid = BaseApi::getContactIDForSearchterm($screen_name, $profile_url, $contact_id, $uid); - $params = ['order' => ['cid' => true], 'limit' => $count]; $condition = ['relation-cid' => $cid, 'follows' => true];