From 04bca818b8a9a8b7f74e4e1c9532e9ed46c60904 Mon Sep 17 00:00:00 2001 From: NoPlagiarism <37241775+NoPlagiarism@users.noreply.github.com> Date: Sat, 10 Jun 2023 20:56:07 +0500 Subject: [PATCH] VKAPI: Re-add Utils.resolveScreenName (#886) --- VKAPI/Handlers/Utils.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/VKAPI/Handlers/Utils.php b/VKAPI/Handlers/Utils.php index 7144a39a..5350a64f 100644 --- a/VKAPI/Handlers/Utils.php +++ b/VKAPI/Handlers/Utils.php @@ -1,5 +1,6 @@ getMatchingRoute("/$screen_name")[0]->presenter !== "UnknownTextRouteStrategy") { + if(substr($screen_name, 0, strlen("id")) === "id") { + return (object) [ + "object_id" => (int) substr($screen_name, strlen("id")), + "type" => "user" + ]; + } else if(substr($screen_name, 0, strlen("club")) === "club") { + return (object) [ + "object_id" => (int) substr($screen_name, strlen("club")), + "type" => "group" + ]; + } + } else { + $user = (new Users)->getByShortURL($screen_name); + if($user) { + return (object) [ + "object_id" => $user->getId(), + "type" => "user" + ]; + } + + $club = (new Clubs)->getByShortURL($screen_name); + if($club) { + return (object) [ + "object_id" => $club->getId(), + "type" => "group" + ]; + } + + return (object) []; + } + } }