X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FDiaspora.php;h=8e2e487796a300c373edddebc880cd9833e3af7f;hb=23830dc45fdb813a4da3d6fe2f9d57974d252738;hp=f7d94256eeaea5ffd654ab39b62686d49fe25a1b;hpb=dc95d7c4f0634c3de9b1b19f6f0bf27e16d5fd61;p=friendica.git diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index f7d94256ee..8e2e487796 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -180,22 +180,28 @@ class Diaspora public static function setRelayContact($server_url, array $network_fields = []) { $fields = ['created' => DateTimeFormat::utcNow(), - 'name' => 'relay', 'nick' => 'relay', - 'url' => $server_url, 'network' => Protocol::DIASPORA, + 'name' => 'relay', 'nick' => 'relay', 'url' => $server_url, + 'nurl' => Strings::normaliseLink($server_url), + 'network' => Protocol::DIASPORA, 'uid' => 0, 'batch' => $server_url . '/receive/public', 'rel' => Contact::FOLLOWER, 'blocked' => false, - 'pending' => false, 'writable' => true]; + 'pending' => false, 'writable' => true, + 'baseurl' => $server_url, 'contact-type' => Contact::TYPE_RELAY]; $fields = array_merge($fields, $network_fields); - $condition = ['uid' => 0, 'nurl' => Strings::normaliseLink($server_url), - 'contact-type' => Contact::TYPE_RELAY]; - - if (DBA::exists('contact', $condition)) { + $condition = ['uid' => 0, 'nurl' => Strings::normaliseLink($server_url)]; + $old = DBA::selectFirst('contact', [], $condition); + if (DBA::isResult($old)) { unset($fields['created']); - } + $condition = ['id' => $old['id']]; - DBA::update('contact', $fields, $condition, true); + Logger::info('Update relay contact', ['fields' => $fields, 'condition' => $condition]); + DBA::update('contact', $fields, $condition, $old); + } else { + Logger::info('Create relay contact', ['fields' => $fields]); + DBA::insert('contact', $fields); + } } /** @@ -2258,8 +2264,8 @@ class Diaspora $fields = ['name' => $name, 'location' => $location, 'name-date' => DateTimeFormat::utcNow(), 'about' => $about, 'gender' => $gender, - 'addr' => $author, 'nick' => $nick, - 'keywords' => $keywords]; + 'addr' => $author, 'nick' => $nick, 'keywords' => $keywords, + 'unsearchable' => !$searchable, 'sensitive' => $nsfw]; if (!empty($birthday)) { $fields['bd'] = $birthday; @@ -2267,6 +2273,8 @@ class Diaspora DBA::update('contact', $fields, ['id' => $contact['id']]); + // @todo Update the public contact, then update the gcontact from that + $gcontact = ["url" => $contact["url"], "network" => Protocol::DIASPORA, "generation" => 2, "photo" => $image_url, "name" => $name, "location" => $location, "about" => $about, "birthday" => $birthday, "gender" => $gender,