mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +03:00
VKAPI: Fix 500 error if some peers_id is invalid
This commit is contained in:
parent
ca27e0588a
commit
c3610cdd4d
1 changed files with 28 additions and 26 deletions
|
@ -247,32 +247,34 @@ final class Messages extends VKAPIRequestHandler
|
|||
|
||||
$user = (new USRRepo)->get((int) $peer);
|
||||
|
||||
$dialogue = new Correspondence($this->getUser(), $user);
|
||||
$iterator = $dialogue->getMessages(Correspondence::CAP_BEHAVIOUR_START_MESSAGE_ID, 0, 1, 0, false);
|
||||
$msg = $iterator[0]->unwrap(); // шоб удобнее было
|
||||
$output['items'][] = [
|
||||
"peer" => [
|
||||
"id" => $user->getId(),
|
||||
"type" => "user",
|
||||
"local_id" => $user->getId()
|
||||
],
|
||||
"last_message_id" => $msg->id,
|
||||
"in_read" => $msg->id,
|
||||
"out_read" => $msg->id,
|
||||
"sort_id" => [
|
||||
"major_id" => 0,
|
||||
"minor_id" => $msg->id, // КОНЕЧНО ЖЕ
|
||||
],
|
||||
"last_conversation_message_id" => $user->getId(),
|
||||
"in_read_cmid" => $user->getId(),
|
||||
"out_read_cmid" => $user->getId(),
|
||||
"is_marked_unread" => $iterator[0]->isUnread(),
|
||||
"important" => false, // целестора когда релиз
|
||||
"can_write" => [
|
||||
"allowed" => ($user->getId() === $this->getUser()->getId() || $user->getPrivacyPermission('messages.write', $this->getUser()) === true)
|
||||
]
|
||||
];
|
||||
$userslist[] = $user->getId();
|
||||
if($user) {
|
||||
$dialogue = new Correspondence($this->getUser(), $user);
|
||||
$iterator = $dialogue->getMessages(Correspondence::CAP_BEHAVIOUR_START_MESSAGE_ID, 0, 1, 0, false);
|
||||
$msg = $iterator[0]->unwrap(); // шоб удобнее было
|
||||
$output['items'][] = [
|
||||
"peer" => [
|
||||
"id" => $user->getId(),
|
||||
"type" => "user",
|
||||
"local_id" => $user->getId()
|
||||
],
|
||||
"last_message_id" => $msg->id,
|
||||
"in_read" => $msg->id,
|
||||
"out_read" => $msg->id,
|
||||
"sort_id" => [
|
||||
"major_id" => 0,
|
||||
"minor_id" => $msg->id, // КОНЕЧНО ЖЕ
|
||||
],
|
||||
"last_conversation_message_id" => $user->getId(),
|
||||
"in_read_cmid" => $user->getId(),
|
||||
"out_read_cmid" => $user->getId(),
|
||||
"is_marked_unread" => $iterator[0]->isUnread(),
|
||||
"important" => false, // целестора когда релиз
|
||||
"can_write" => [
|
||||
"allowed" => ($user->getId() === $this->getUser()->getId() || $user->getPrivacyPermission('messages.write', $this->getUser()) === true)
|
||||
]
|
||||
];
|
||||
$userslist[] = $user->getId();
|
||||
}
|
||||
}
|
||||
|
||||
if($extended == 1) {
|
||||
|
|
Loading…
Reference in a new issue