+ /**
+ * @brief Helper function for updateFromPublicContactID and updateFromPublicContactURL
+ *
+ * @param array $condition contact condition
+ * @return integer gcontact id
+ * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+ * @throws \ImagickException
+ */
+ private static function updateFromPublicContact($condition)
+ {
+ $fields = ['name', 'nick', 'url', 'nurl', 'location', 'about', 'keywords', 'gender',
+ 'bd', 'contact-type', 'network', 'addr', 'notify', 'alias', 'archive', 'term-date',
+ 'created', 'updated', 'avatar', 'success_update', 'failure_update', 'forum', 'prv',
+ 'baseurl', 'sensitive', 'unsearchable'];
+
+ $contact = DBA::selectFirst('contact', $fields, array_merge($condition, ['uid' => 0, 'network' => Protocol::FEDERATED]));
+ if (!DBA::isResult($contact)) {
+ return 0;
+ }
+
+ $fields = ['name', 'nick', 'url', 'nurl', 'location', 'about', 'keywords', 'gender', 'generation',
+ 'birthday', 'contact-type', 'network', 'addr', 'notify', 'alias', 'archived', 'archive_date',
+ 'created', 'updated', 'photo', 'last_contact', 'last_failure', 'community', 'connect',
+ 'server_url', 'nsfw', 'hide', 'id'];
+
+ $old_gcontact = DBA::selectFirst('gcontact', $fields, ['nurl' => $contact['nurl']]);
+ $do_insert = !DBA::isResult($old_gcontact);
+ if ($do_insert) {
+ $old_gcontact = [];
+ }
+
+ $gcontact = [];
+
+ // These fields are identical in both contact and gcontact
+ $fields = ['name', 'nick', 'url', 'nurl', 'location', 'about', 'keywords', 'gender',
+ 'contact-type', 'network', 'addr', 'notify', 'alias', 'created', 'updated'];
+
+ foreach ($fields as $field) {
+ $gcontact[$field] = $contact[$field];