Use the owner data to collect all data

This commit is contained in:
Michael 2020-08-18 17:30:48 +00:00
parent c3bfa9f1c1
commit f1a8db4e76

View File

@ -2167,20 +2167,18 @@ class Probe
public static function localProbe($url) public static function localProbe($url)
{ {
$fields = ['uid', 'url', 'name', 'nick', 'addr', 'alias', 'photo', 'contact-type', 'keywords', $self = Contact::selectFirst(['uid'], ['self' => true, 'nurl' => Strings::normaliseLink($url)]);
'location', 'about', 'notify', 'poll', 'request', 'confirm', 'poco', 'pubkey', 'gsid']; if (empty($self['uid'])) {
$self = Contact::selectFirst($fields, ['self' => true, 'nurl' => Strings::normaliseLink($url)]); $self = Contact::selectFirst(['uid'], ['self' => true, 'addr' => $url]);
if (empty($self)) {
$self = Contact::selectFirst($fields, ['self' => true, 'addr' => $url]);
} }
if (empty($self)) { if (empty($self['uid'])) {
$self = Contact::selectFirst($fields, ['self' => true, 'alias' => [$url, Strings::normaliseLink($url)]]); $self = Contact::selectFirst(['uid'], ['self' => true, 'alias' => [$url, Strings::normaliseLink($url)]]);
} }
if (empty($self)) { if (empty($self['uid'])) {
return []; return [];
} }
$profile = Profile::getByUID($self['uid']); $profile = User::getOwnerDataById($self['uid']);
if (empty($profile)) { if (empty($profile)) {
return []; return [];
} }
@ -2190,22 +2188,22 @@ class Probe
return []; return [];
} }
if (empty($self['gsid'])) { if (empty($profile['gsid'])) {
$self['gsid'] = GServer::getID($approfile['generator']['url']); $profile['gsid'] = GServer::getID($approfile['generator']['url']);
} }
$data = ['name' => $self['name'], 'nick' => $self['nick'], 'guid' => $approfile['diaspora:guid'], $data = ['name' => $profile['name'], 'nick' => $profile['nick'], 'guid' => $approfile['diaspora:guid'],
'url' => $self['url'], 'addr' => $self['addr'], 'alias' => $self['alias'], 'url' => $profile['url'], 'addr' => $profile['addr'], 'alias' => $profile['alias'],
'photo' => $self['photo'], 'account-type' => $self['contact-type'], 'photo' => $profile['photo'], 'account-type' => $profile['contact-type'],
'community' => ($self['contact-type'] == Contact::TYPE_COMMUNITY), 'community' => ($profile['contact-type'] == Contact::TYPE_COMMUNITY),
'keywords' => $self['keywords'], 'location' => $self['location'], 'about' => $self['about'], 'keywords' => $profile['keywords'], 'location' => $profile['location'], 'about' => $profile['about'],
'hide' => !$profile['net-publish'], 'batch' => '', 'notify' => $self['notify'], 'hide' => !$profile['net-publish'], 'batch' => '', 'notify' => $profile['notify'],
'poll' => $self['poll'], 'request' => $self['request'], 'confirm' => $self['confirm'], 'poll' => $profile['poll'], 'request' => $profile['request'], 'confirm' => $profile['confirm'],
'subscribe' => $approfile['generator']['url'] . '/follow?url={uri}', 'poco' => $self['poco'], 'subscribe' => $approfile['generator']['url'] . '/follow?url={uri}', 'poco' => $profile['poco'],
'following' => $approfile['following'], 'followers' => $approfile['followers'], 'following' => $approfile['following'], 'followers' => $approfile['followers'],
'inbox' => $approfile['inbox'], 'outbox' => $approfile['outbox'], 'inbox' => $approfile['inbox'], 'outbox' => $approfile['outbox'],
'sharedinbox' => $approfile['endpoints']['sharedInbox'], 'network' => Protocol::DFRN, 'sharedinbox' => $approfile['endpoints']['sharedInbox'], 'network' => Protocol::DFRN,
'pubkey' => $self['pubkey'], 'baseurl' => $approfile['generator']['url'], 'gsid' => $self['gsid']]; 'pubkey' => $profile['upubkey'], 'baseurl' => $approfile['generator']['url'], 'gsid' => $profile['gsid']];
return self::rearrangeData($data); return self::rearrangeData($data);
} }
} }