Use "User::getIdForURL"
This commit is contained in:
parent
f1a8db4e76
commit
5aba1df497
2 changed files with 27 additions and 18 deletions
|
@ -162,14 +162,24 @@ class User
|
||||||
* @return integer user id
|
* @return integer user id
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function getIdForURL($url)
|
public static function getIdForURL(string $url)
|
||||||
{
|
{
|
||||||
$self = DBA::selectFirst('contact', ['uid'], ['nurl' => Strings::normaliseLink($url), 'self' => true]);
|
$self = Contact::selectFirst(['uid'], ['self' => true, 'nurl' => Strings::normaliseLink($url)]);
|
||||||
if (!DBA::isResult($self)) {
|
if (!empty($self['uid'])) {
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return $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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,7 +29,6 @@ use Friendica\Core\Protocol;
|
||||||
use Friendica\Core\System;
|
use Friendica\Core\System;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
|
||||||
use Friendica\Model\GServer;
|
use Friendica\Model\GServer;
|
||||||
use Friendica\Model\Profile;
|
use Friendica\Model\Profile;
|
||||||
use Friendica\Model\User;
|
use Friendica\Model\User;
|
||||||
|
@ -2165,25 +2164,25 @@ class Probe
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function localProbe($url)
|
/**
|
||||||
|
* Probe data from local profiles without network traffic
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* @return array probed data
|
||||||
|
*/
|
||||||
|
public static function localProbe(string $url)
|
||||||
{
|
{
|
||||||
$self = Contact::selectFirst(['uid'], ['self' => true, 'nurl' => Strings::normaliseLink($url)]);
|
$uid = User::getIdForURL($url);
|
||||||
if (empty($self['uid'])) {
|
if (empty($uid)) {
|
||||||
$self = Contact::selectFirst(['uid'], ['self' => true, 'addr' => $url]);
|
|
||||||
}
|
|
||||||
if (empty($self['uid'])) {
|
|
||||||
$self = Contact::selectFirst(['uid'], ['self' => true, 'alias' => [$url, Strings::normaliseLink($url)]]);
|
|
||||||
}
|
|
||||||
if (empty($self['uid'])) {
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = User::getOwnerDataById($self['uid']);
|
$profile = User::getOwnerDataById($uid);
|
||||||
if (empty($profile)) {
|
if (empty($profile)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$approfile = ActivityPub\Transmitter::getProfile($self['uid']);
|
$approfile = ActivityPub\Transmitter::getProfile($uid);
|
||||||
if (empty($approfile)) {
|
if (empty($approfile)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -2195,7 +2194,7 @@ class Probe
|
||||||
$data = ['name' => $profile['name'], 'nick' => $profile['nick'], 'guid' => $approfile['diaspora:guid'],
|
$data = ['name' => $profile['name'], 'nick' => $profile['nick'], 'guid' => $approfile['diaspora:guid'],
|
||||||
'url' => $profile['url'], 'addr' => $profile['addr'], 'alias' => $profile['alias'],
|
'url' => $profile['url'], 'addr' => $profile['addr'], 'alias' => $profile['alias'],
|
||||||
'photo' => $profile['photo'], 'account-type' => $profile['contact-type'],
|
'photo' => $profile['photo'], 'account-type' => $profile['contact-type'],
|
||||||
'community' => ($profile['contact-type'] == Contact::TYPE_COMMUNITY),
|
'community' => ($profile['contact-type'] == User::ACCOUNT_TYPE_COMMUNITY),
|
||||||
'keywords' => $profile['keywords'], 'location' => $profile['location'], 'about' => $profile['about'],
|
'keywords' => $profile['keywords'], 'location' => $profile['location'], 'about' => $profile['about'],
|
||||||
'hide' => !$profile['net-publish'], 'batch' => '', 'notify' => $profile['notify'],
|
'hide' => !$profile['net-publish'], 'batch' => '', 'notify' => $profile['notify'],
|
||||||
'poll' => $profile['poll'], 'request' => $profile['request'], 'confirm' => $profile['confirm'],
|
'poll' => $profile['poll'], 'request' => $profile['request'], 'confirm' => $profile['confirm'],
|
||||||
|
|
Loading…
Reference in a new issue