mirror of
https://github.com/openvk/openvk
synced 2025-01-22 15:54:26 +03:00
ActivityPub, Users: Add more functionality to getByShortUrl, add fetching by id[0-9]
This commit is contained in:
parent
6119b92dc2
commit
8dcafff002
2 changed files with 11 additions and 3 deletions
|
@ -28,9 +28,17 @@ class Users
|
|||
return $this->toUser($this->users->get($id));
|
||||
}
|
||||
|
||||
function getByShortURL(string $url): ?User
|
||||
function getByShortURL(string $url, bool $handleId = false): ?User
|
||||
{
|
||||
return $this->toUser($this->users->where("shortcode", $url)->fetch());
|
||||
$user = $this->toUser($this->users->where("shortcode", $url)->fetch());
|
||||
if($user)
|
||||
return $user
|
||||
else if ($handleId == true)
|
||||
{
|
||||
preg_match("/id([0-9]+)/", $url, $id);
|
||||
return $this->toUser($this->users->get($id[1]));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function getByChandlerUser(ChandlerUser $user): ?User
|
||||
|
|
|
@ -27,7 +27,7 @@ final class ActivityPubPresenter extends OpenVKPresenter
|
|||
preg_match('/([a-zA-Z0-9-_]+)@([a-zA-Z0-9-_\.]+)/', $subject, $username);
|
||||
$username = $username[1];
|
||||
|
||||
$user = (new Users)->getByShortURL($username);
|
||||
$user = (new Users)->getByShortURL($username, true);
|
||||
|
||||
if($user !== null) {
|
||||
$response->subject = $this->requestParam("resource");
|
||||
|
|
Loading…
Reference in a new issue