Don't probe non existing local contacts

pull/10508/head
Michael 2021-07-19 04:49:58 +00:00
rodzic aa6313dee6
commit 01abea7c25
1 zmienionych plików z 24 dodań i 30 usunięć

Wyświetl plik

@ -2201,20 +2201,9 @@ class Probe
*/ */
private static function localProbe(string $url) private static function localProbe(string $url)
{ {
$uid = User::getIdForURL($url); if ($uid = User::getIdForURL($url)) {
if (empty($uid)) {
return [];
}
$profile = User::getOwnerDataById($uid); $profile = User::getOwnerDataById($uid);
if (empty($profile)) {
return [];
}
$approfile = ActivityPub\Transmitter::getProfile($uid); $approfile = ActivityPub\Transmitter::getProfile($uid);
if (empty($approfile)) {
return [];
}
if (empty($profile['gsid'])) { if (empty($profile['gsid'])) {
$profile['gsid'] = GServer::getID($approfile['generator']['url']); $profile['gsid'] = GServer::getID($approfile['generator']['url']);
@ -2234,6 +2223,11 @@ class Probe
'sharedinbox' => $approfile['endpoints']['sharedInbox'], 'network' => Protocol::DFRN, 'sharedinbox' => $approfile['endpoints']['sharedInbox'], 'network' => Protocol::DFRN,
'pubkey' => $profile['upubkey'], 'baseurl' => $approfile['generator']['url'], 'gsid' => $profile['gsid'], 'pubkey' => $profile['upubkey'], 'baseurl' => $approfile['generator']['url'], 'gsid' => $profile['gsid'],
'manually-approve' => in_array($profile['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP])]; 'manually-approve' => in_array($profile['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP])];
} else {
// Default values for non existing targets
$data = ['name' => $url, 'nick' => $url, 'url' => $url, 'network' => Protocol::PHANTOM,
'photo' => DI::baseUrl() . Contact::DEFAULT_AVATAR_PHOTO];
}
return self::rearrangeData($data); return self::rearrangeData($data);
} }
} }