Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion VKAPI/Handlers/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public function getInfo(): object
"country" => "CZ", # TODO
"eu_user" => false, # TODO
"https_required" => 1,
"phone" => "+*** ** *** ***",
"phone" => "",
"link_redirects" => "{}",
"intro" => 0,
"community_comments" => false,
"is_live_streaming_enabled" => false,
Expand Down
7 changes: 7 additions & 0 deletions VKAPI/Handlers/Messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -3532,6 +3532,13 @@ public function getHistoryAttachments(
$this->hydrateExtendedData($data, $fields);
}

if (!isset($data["items"]) || !is_array($data["items"])) {
$data["items"] = [];
}
if (!isset($data["next_from"]) || !is_string($data["next_from"])) {
$data["next_from"] = "";
}

return (object) $data;
}

Expand Down
3 changes: 2 additions & 1 deletion VKAPI/Handlers/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public function subscribe(string $queue_id = "", string $queue_ids = "", int $ts
{
$this->requireUser();

$baseUrl = IMBroker::i()->getLongPollBaseUrl();
$scheme = ((($_SERVER["HTTP_X_FORWARDED_PROTO"] ?? "") === "https") || ovk_is_ssl()) ? "https://" : "http://";
$baseUrl = preg_replace("~^https?://~i", $scheme, str_replace("/nim", "/queue", IMBroker::i()->getLongPollBaseUrl()), 1);
$now = time();

$ids = [];
Expand Down
23 changes: 21 additions & 2 deletions VKAPI/Handlers/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public function get(string $user_ids = "0", string $fields = "", int $offset = 0
"id" => $usr->getId(),
"first_name" => $firstName,
"last_name" => $lastName,
"is_closed" => (bool) $usr->isClosed(),
"can_access_closed" => (bool) $canView,
"is_closed" => $this->usesBooleanClosedFlags() ? (bool) $usr->isClosed() : (int) $usr->isClosed(),
"can_access_closed" => $this->usesBooleanClosedFlags() ? (bool) $canView : (int) $canView,
];
$response[$i]->photo_base = $usr->getAvatarUrl("normal");

Expand Down Expand Up @@ -744,4 +744,23 @@ public function report(int $user_id, string $type = "spam", string $comment = ""

return 1;
}

/**
* Modern VK API versions (>= 5.200, e.g. the VK Messenger client) expect
* users.get is_closed/can_access_closed as JSON booleans, while older
* clients (OpenVK Legacy/Refresh/iOS, Kate/FreeKate) read them as integers.
* Gate the type by the requested API version to keep both working.
*/
private function usesBooleanClosedFlags(): bool
{
if (!defined("VKAPI_DECL_VER_MAJOR")) {
return false;
}
if (VKAPI_DECL_VER_MAJOR > 5) {
return true;
}
return VKAPI_DECL_VER_MAJOR === 5
&& defined("VKAPI_DECL_VER_MINOR")
&& VKAPI_DECL_VER_MINOR >= 200;
}
}
Loading