Skip to content

Commit

Permalink
fix(api): 500 error if user from repost does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
veselcraft committed Dec 1, 2023
1 parent 5b8fe91 commit 1625557
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions VKAPI/Handlers/Wall.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,19 +435,28 @@ function getById(string $posts, int $extended = 0, string $fields = "", User $us

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

foreach($groups as $g) {
Expand Down

0 comments on commit 1625557

Please sign in to comment.