mirror of
https://github.com/openvk/openvk
synced 2024-12-22 16:42:32 +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)
|
||||
];
|
||||
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")),
|
||||
"type" => "group"
|
||||
];
|
||||
}
|
||||
} else $this->fail(104, "Not found");
|
||||
} else {
|
||||
$user = (new Users)->getByShortURL($screen_name);
|
||||
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();
|
||||
}
|
||||
|
||||
function getByChandlerUserId(string $cid): ?User
|
||||
{
|
||||
return $this->toUser($this->users->where("user", $cid)->fetch());
|
||||
}
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue