VKAPI: Fix bug when DELETED user appear if there is no user_ids

This commit is contained in:
veselcraft 2022-08-25 01:43:52 +03:00
parent 643208dff0
commit 47c13e1234
No known key found for this signature in database
GPG key ID: AED66BC1AC628A4E

View file

@ -14,7 +14,7 @@ final class Users extends VKAPIRequestHandler
$user_ids = (string) $authuser->getId(); $user_ids = (string) $authuser->getId();
$usrs = explode(',', $user_ids); $usrs = explode(',', $user_ids);
$response; $response = array();
$ic = sizeof($usrs); $ic = sizeof($usrs);
@ -24,117 +24,122 @@ final class Users extends VKAPIRequestHandler
$usrs = array_slice($usrs, $offset * $count); $usrs = array_slice($usrs, $offset * $count);
for($i=0; $i < $ic; $i++) { for($i=0; $i < $ic; $i++) {
$usr = $users->get((int) $usrs[$i]); if($usrs[$i] != 0) {
if(is_null($usr) || $usr->isDeleted()) { $usr = $users->get((int) $usrs[$i]);
$response[$i] = (object)[ if(is_null($usr) || $usr->isDeleted()) {
"id" => (int) $usrs[$i], $response[$i] = (object)[
"first_name" => "DELETED", "id" => (int) $usrs[$i],
"last_name" => "", "first_name" => "DELETED",
"deactivated" => "deleted" "last_name" => "",
]; "deactivated" => "deleted"
} else if($usrs[$i] == NULL) { ];
} else if($usrs[$i] == NULL) {
} else { } else {
$response[$i] = (object)[ $response[$i] = (object)[
"id" => $usr->getId(), "id" => $usr->getId(),
"first_name" => $usr->getFirstName(), "first_name" => $usr->getFirstName(),
"last_name" => $usr->getLastName(), "last_name" => $usr->getLastName(),
"is_closed" => false, "is_closed" => false,
"can_access_closed" => true, "can_access_closed" => true,
]; ];
$flds = explode(',', $fields); $flds = explode(',', $fields);
foreach($flds as $field) { foreach($flds as $field) {
switch($field) { switch($field) {
case "verified": case "verified":
$response[$i]->verified = intval($usr->isVerified()); $response[$i]->verified = intval($usr->isVerified());
break; break;
case "sex": case "sex":
$response[$i]->sex = $usr->isFemale() ? 1 : 2; $response[$i]->sex = $usr->isFemale() ? 1 : 2;
break; break;
case "has_photo": case "has_photo":
$response[$i]->has_photo = is_null($usr->getAvatarPhoto()) ? 0 : 1; $response[$i]->has_photo = is_null($usr->getAvatarPhoto()) ? 0 : 1;
break; break;
case "photo_max_orig": case "photo_max_orig":
$response[$i]->photo_max_orig = $usr->getAvatarURL(); $response[$i]->photo_max_orig = $usr->getAvatarURL();
break; break;
case "photo_max": case "photo_max":
$response[$i]->photo_max = $usr->getAvatarURL("original"); $response[$i]->photo_max = $usr->getAvatarURL("original");
break; break;
case "photo_50": case "photo_50":
$response[$i]->photo_50 = $usr->getAvatarURL(); $response[$i]->photo_50 = $usr->getAvatarURL();
break; break;
case "photo_100": case "photo_100":
$response[$i]->photo_100 = $usr->getAvatarURL("tiny"); $response[$i]->photo_100 = $usr->getAvatarURL("tiny");
break; break;
case "photo_200": case "photo_200":
$response[$i]->photo_200 = $usr->getAvatarURL("normal"); $response[$i]->photo_200 = $usr->getAvatarURL("normal");
break; break;
case "photo_200_orig": # вообще не ебу к чему эта строка ну пусть будет кек case "photo_200_orig": # вообще не ебу к чему эта строка ну пусть будет кек
$response[$i]->photo_200_orig = $usr->getAvatarURL("normal"); $response[$i]->photo_200_orig = $usr->getAvatarURL("normal");
break; break;
case "photo_400_orig": case "photo_400_orig":
$response[$i]->photo_400_orig = $usr->getAvatarURL("normal"); $response[$i]->photo_400_orig = $usr->getAvatarURL("normal");
break; break;
# Она хочет быть выебанной видя матан # Она хочет быть выебанной видя матан
# Покайфу когда ты Виет а вокруг лишь дискриминант # Покайфу когда ты Виет а вокруг лишь дискриминант
case "status":
if($usr->getStatus() != NULL)
$response[$i]->status = $usr->getStatus();
break;
case "screen_name":
if($usr->getShortCode() != NULL)
$response[$i]->screen_name = $usr->getShortCode();
break;
case "friend_status":
switch($usr->getSubscriptionStatus($authuser)) {
case 3:
# NOTICE falling through
case 0:
$response[$i]->friend_status = $usr->getSubscriptionStatus($authuser);
break;
case 1:
$response[$i]->friend_status = 2;
break;
case 2:
$response[$i]->friend_status = 1;
break;
}
break;
case "last_seen":
if ($usr->onlineStatus() == 0)
$response[$i]->last_seen = (object) [
"platform" => 1,
"time" => $usr->getOnline()->timestamp()
];
case "music":
$response[$i]->music = $usr->getFavoriteMusic();
break;
case "movies":
$response[$i]->movies = $usr->getFavoriteFilms();
break;
case "tv":
$response[$i]->tv = $usr->getFavoriteShows();
break;
case "books":
$response[$i]->books = $usr->getFavoriteBooks();
break;
case "city":
$response[$i]->city = $usr->getCity();
break;
case "interests":
$response[$i]->interests = $usr->getInterests();
break;
}
}
if($usr->getOnline()->timestamp() + 300 > time()) # ору а когда я это успел написать
$response[$i]->online = 1; # вова кстати не матерись в коде мамка же спалит азщазаззазщазазаззазазазх
else case "status":
$response[$i]->online = 0; if($usr->getStatus() != NULL)
} $response[$i]->status = $usr->getStatus();
break;
case "screen_name":
if($usr->getShortCode() != NULL)
$response[$i]->screen_name = $usr->getShortCode();
break;
case "friend_status":
switch($usr->getSubscriptionStatus($authuser)) {
case 3:
# NOTICE falling through
case 0:
$response[$i]->friend_status = $usr->getSubscriptionStatus($authuser);
break;
case 1:
$response[$i]->friend_status = 2;
break;
case 2:
$response[$i]->friend_status = 1;
break;
}
break;
case "last_seen":
if ($usr->onlineStatus() == 0)
$response[$i]->last_seen = (object) [
"platform" => 1,
"time" => $usr->getOnline()->timestamp()
];
case "music":
$response[$i]->music = $usr->getFavoriteMusic();
break;
case "movies":
$response[$i]->movies = $usr->getFavoriteFilms();
break;
case "tv":
$response[$i]->tv = $usr->getFavoriteShows();
break;
case "books":
$response[$i]->books = $usr->getFavoriteBooks();
break;
case "city":
$response[$i]->city = $usr->getCity();
break;
case "interests":
$response[$i]->interests = $usr->getInterests();
break;
}
}
if($usr->getOnline()->timestamp() + 300 > time())
$response[$i]->online = 1;
else
$response[$i]->online = 0;
}
}
} }
return $response; return $response;