Use "User::getIdForURL"

This commit is contained in:
Michael 2020-08-18 19:45:01 +00:00
parent f1a8db4e76
commit 5aba1df497
2 changed files with 27 additions and 18 deletions

View file

@ -162,14 +162,24 @@ class User
* @return integer user id
* @throws Exception
*/
public static function getIdForURL($url)
public static function getIdForURL(string $url)
{
$self = DBA::selectFirst('contact', ['uid'], ['nurl' => Strings::normaliseLink($url), 'self' => true]);
if (!DBA::isResult($self)) {
return false;
} else {
$self = Contact::selectFirst(['uid'], ['self' => true, 'nurl' => Strings::normaliseLink($url)]);
if (!empty($self['uid'])) {
return $self['uid'];
}
$self = Contact::selectFirst(['uid'], ['self' => true, 'addr' => $url]);
if (!empty($self['uid'])) {
return $self['uid'];
}
$self = Contact::selectFirst(['uid'], ['self' => true, 'alias' => [$url, Strings::normaliseLink($url)]]);
if (!empty($self['uid'])) {
return $self['uid'];
}
return 0;
}
/**