* @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;
}
/**