fix(api): 500 error if user from repost does not exist

This commit is contained in:
veselcraft 2023-12-01 15:10:13 +03:00
parent 5b8fe91a33
commit 1625557e24
No known key found for this signature in database
GPG key ID: 9CF0B42766CCF7BA

View file

@ -435,19 +435,28 @@ final class Wall extends VKAPIRequestHandler
foreach($profiles as $prof) { foreach($profiles as $prof) {
$user = (new UsersRepo)->get($prof); $user = (new UsersRepo)->get($prof);
if($user) {
$profilesFormatted[] = (object)[ $profilesFormatted[] = (object)[
"first_name" => $user->getFirstName(), "first_name" => $user->getFirstName(),
"id" => $user->getId(), "id" => $user->getId(),
"last_name" => $user->getLastName(), "last_name" => $user->getLastName(),
"can_access_closed" => false, "can_access_closed" => false,
"is_closed" => false, "is_closed" => false,
"sex" => $user->isFemale() ? 1 : ($user->isNeutral() ? 0 : 2), "sex" => $user->isFemale() ? 1 : 2,
"screen_name" => $user->getShortCode(), "screen_name" => $user->getShortCode(),
"photo_50" => $user->getAvatarUrl(), "photo_50" => $user->getAvatarUrl(),
"photo_100" => $user->getAvatarUrl(), "photo_100" => $user->getAvatarUrl(),
"online" => $user->isOnline(), "online" => $user->isOnline(),
"verified" => $user->isVerified() "verified" => $user->isVerified()
]; ];
} else {
$profilesFormatted[] = (object)[
"id" => (int) $prof,
"first_name" => "DELETED",
"last_name" => "",
"deactivated" => "deleted"
];
}
} }
foreach($groups as $g) { foreach($groups as $g) {