From e1d4f96b060d5670e9723ed304b6fc52b261d9c4 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 21 Nov 2021 20:14:48 +0000 Subject: [PATCH] Remove unused user fields --- include/api.php | 29 +++++++++-------------------- src/Object/Api/Twitter/User.php | 2 -- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/include/api.php b/include/api.php index 5d6fb2add..e7706b44a 100644 --- a/include/api.php +++ b/include/api.php @@ -264,16 +264,15 @@ function api_account_verify_credentials($type) // - Adding last status if (!$skip_status) { - $item = api_get_last_status($user_info['pid'], $user_info['uid']); + $item = api_get_last_status($user_info['pid'], 0); if (!empty($item)) { $user_info['status'] = api_format_item($item, $type); } } - // "uid" and "self" are only needed for some internal stuff, so remove it from here + // "uid" is only needed for some internal stuff, so remove it from here unset($user_info['uid']); - unset($user_info['self']); - + return DI::apiResponse()->formatData("user", $type, ['user' => $user_info]); } @@ -697,14 +696,13 @@ function api_users_show($type) $user_info = DI::twitterUser()->createFromUserId($uid)->toArray(); - $item = api_get_last_status($user_info['pid'], $user_info['uid']); + $item = api_get_last_status($user_info['pid'], 0); if (!empty($item)) { $user_info['status'] = api_format_item($item, $type); } - // "uid" and "self" are only needed for some internal stuff, so remove it from here + // "uid" is only needed for some internal stuff, so remove it from here unset($user_info['uid']); - unset($user_info['self']); return DI::apiResponse()->formatData('user', $type, ['user' => $user_info]); } @@ -1670,19 +1668,13 @@ function api_format_messages($item, $recipient, $sender) 'friendica_parent_uri' => $item['parent-uri'] ?? '', ]; - // "uid" and "self" are only needed for some internal stuff, so remove it from here + // "uid" is only needed for some internal stuff, so remove it from here if (isset($ret['sender']['uid'])) { unset($ret['sender']['uid']); } - if (isset($ret['sender']['self'])) { - unset($ret['sender']['self']); - } if (isset($ret['recipient']['uid'])) { unset($ret['recipient']['uid']); } - if (isset($ret['recipient']['self'])) { - unset($ret['recipient']['self']); - } //don't send title to regular StatusNET requests to avoid confusing these apps if (!empty($_GET['getText'])) { @@ -2268,9 +2260,8 @@ function api_format_item($item, $type = "json") $status['quoted_status'] = $quoted_status; } - // "uid" and "self" are only needed for some internal stuff, so remove it from here + // "uid" is only needed for some internal stuff, so remove it from here unset($status["user"]['uid']); - unset($status["user"]['self']); if ($item["coord"] != "") { $coords = explode(' ', $item["coord"]); @@ -2494,9 +2485,8 @@ function api_statuses_f($qtype) $ret = []; foreach ($r as $cid) { $user = DI::twitterUser()->createFromContactId($cid['id'], $uid)->toArray(); - // "uid" and "self" are only needed for some internal stuff, so remove it from here + // "uid" is only needed for some internal stuff, so remove it from here unset($user['uid']); - unset($user['self']); if ($user) { $ret[] = $user; @@ -2794,9 +2784,8 @@ function api_friendships_destroy($type) throw new HTTPException\InternalServerErrorException('Unable to unfollow this contact, please contact your administrator'); } - // "uid" and "self" are only needed for some internal stuff, so remove it from here + // "uid" is only needed for some internal stuff, so remove it from here unset($contact['uid']); - unset($contact['self']); // Set screen_name since Twidere requests it $contact['screen_name'] = $contact['nick']; diff --git a/src/Object/Api/Twitter/User.php b/src/Object/Api/Twitter/User.php index 75263e9b7..bbc4efc0a 100644 --- a/src/Object/Api/Twitter/User.php +++ b/src/Object/Api/Twitter/User.php @@ -160,8 +160,6 @@ class User extends BaseDataTransferObject $this->uid = (int)$uid; $this->cid = (int)($userContact['id'] ?? 0); $this->pid = (int)$publicContact['id']; - $this->self = (boolean)($userContact['self'] ?? false); - $this->network = $publicContact['network'] ?: Protocol::DFRN; $this->statusnet_profile_url = $publicContact['url']; } }