mirror of
https://github.com/openvk/openvk
synced 2024-11-14 19:19:14 +03:00
improvement(API): fix inconsistencies in util.* + add chandler guid resolving funs
This commit is contained in:
parent
869712d73a
commit
c4fb793333
3 changed files with 21 additions and 4 deletions
|
@ -246,6 +246,9 @@ final class Users extends VKAPIRequestHandler
|
||||||
"notes_count" => (new Notes)->getUserNotesCount($usr)
|
"notes_count" => (new Notes)->getUserNotesCount($usr)
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
case "guid":
|
||||||
|
$response[$i]->guid = $usr->getChandlerGUID();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ final class Utils extends VKAPIRequestHandler
|
||||||
"object_id" => (int) substr($screen_name, strlen("club")),
|
"object_id" => (int) substr($screen_name, strlen("club")),
|
||||||
"type" => "group"
|
"type" => "group"
|
||||||
];
|
];
|
||||||
}
|
} else $this->fail(104, "Not found");
|
||||||
} else {
|
} else {
|
||||||
$user = (new Users)->getByShortURL($screen_name);
|
$user = (new Users)->getByShortURL($screen_name);
|
||||||
if($user) {
|
if($user) {
|
||||||
|
@ -40,7 +40,16 @@ final class Utils extends VKAPIRequestHandler
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return (object) [];
|
$this->fail(104, "Not found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolveGuid(string $guid): object
|
||||||
|
{
|
||||||
|
$user = (new Users)->getByChandlerUserId($guid);
|
||||||
|
if (is_null($user))
|
||||||
|
$this->fail(104, "Not found");
|
||||||
|
|
||||||
|
return $user->toVkApiStruct($this->getUser());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,9 +44,14 @@ class Users
|
||||||
return $alias->getUser();
|
return $alias->getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getByChandlerUserId(string $cid): ?User
|
||||||
|
{
|
||||||
|
return $this->toUser($this->users->where("user", $cid)->fetch());
|
||||||
|
}
|
||||||
|
|
||||||
function getByChandlerUser(?ChandlerUser $user): ?User
|
function getByChandlerUser(?ChandlerUser $user): ?User
|
||||||
{
|
{
|
||||||
return $user ? $this->toUser($this->users->where("user", $user->getId())->fetch()) : NULL;
|
return $user ? $this->getByChandlerUserId($user->getId()) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
function find(string $query, array $pars = [], string $sort = "id DESC"): Util\EntityStream
|
function find(string $query, array $pars = [], string $sort = "id DESC"): Util\EntityStream
|
||||||
|
|
Loading…
Reference in a new issue