diff --git a/VKAPI/Handlers/Account.php b/VKAPI/Handlers/Account.php index 4c07291ec..05bc88884 100644 --- a/VKAPI/Handlers/Account.php +++ b/VKAPI/Handlers/Account.php @@ -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, diff --git a/VKAPI/Handlers/Messages.php b/VKAPI/Handlers/Messages.php index 7ed4c2b8c..2e3b9b8d0 100644 --- a/VKAPI/Handlers/Messages.php +++ b/VKAPI/Handlers/Messages.php @@ -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; } diff --git a/VKAPI/Handlers/Queue.php b/VKAPI/Handlers/Queue.php index 7438310db..fad393043 100644 --- a/VKAPI/Handlers/Queue.php +++ b/VKAPI/Handlers/Queue.php @@ -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 = []; diff --git a/VKAPI/Handlers/Users.php b/VKAPI/Handlers/Users.php index 21b953db5..f17a684ef 100644 --- a/VKAPI/Handlers/Users.php +++ b/VKAPI/Handlers/Users.php @@ -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"); @@ -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; + } }