$contact['network'] = Protocol::OSTATUS;
}
- // All new contacts are hidden by default
- if (!isset($contact['hide'])) {
- $contact['hide'] = true;
- }
-
// Remove unwanted parts from the contact url (e.g. '?zrl=...')
if (in_array($contact['network'], Protocol::FEDERATED)) {
$contact['url'] = self::cleanContactUrl($contact['url']);
$contact['location'] = $contact['location'] ?? '';
$contact['about'] = $contact['about'] ?? '';
$contact['generation'] = $contact['generation'] ?? 0;
+ $contact['hide'] = $contact['hide'] ?? true;
$fields = ['name' => $contact['name'], 'nick' => $contact['nick'] ?? '', 'addr' => $contact['addr'] ?? '', 'network' => $contact['network'],
'url' => $contact['url'], 'nurl' => Strings::normaliseLink($contact['url']), 'photo' => $contact['photo'],
}
$public_contact = DBA::selectFirst('gcontact', [
- 'name', 'nick', 'photo', 'location', 'about', 'addr', 'generation', 'birthday', 'keywords',
+ 'name', 'nick', 'photo', 'location', 'about', 'addr', 'generation', 'birthday', 'keywords', 'gsid',
'contact-type', 'hide', 'nsfw', 'network', 'alias', 'notify', 'server_url', 'connect', 'updated', 'url'
], ['id' => $gcontact_id]);
$contact['server_url'] = Strings::normaliseLink($contact['server_url']);
}
+ if (!empty($contact['server_url']) && empty($contact['gsid'])) {
+ $contact['gsid'] = GServer::getID($contact['server_url']);
+ }
+
if (empty($contact['addr']) && !empty($contact['server_url']) && !empty($contact['nick'])) {
$hostname = str_replace('http://', '', $contact['server_url']);
$contact['addr'] = $contact['nick'] . '@' . $hostname;
'notify' => $contact['notify'], 'url' => $contact['url'],
'location' => $contact['location'], 'about' => $contact['about'],
'generation' => $contact['generation'], 'updated' => $contact['updated'],
- 'server_url' => $contact['server_url'], 'connect' => $contact['connect']
+ 'server_url' => $contact['server_url'], 'connect' => $contact['connect'],
+ 'gsid' => $contact['gsid']
];
DBA::update('gcontact', $updated, $condition, $fields);
$fields = ['name', 'nick', 'url', 'nurl', 'location', 'about', 'keywords',
'bd', 'contact-type', 'network', 'addr', 'notify', 'alias', 'archive', 'term-date',
'created', 'updated', 'avatar', 'success_update', 'failure_update', 'forum', 'prv',
- 'baseurl', 'sensitive', 'unsearchable'];
+ 'baseurl', 'gsid', 'sensitive', 'unsearchable'];
$contact = DBA::selectFirst('contact', $fields, array_merge($condition, ['uid' => 0, 'network' => Protocol::FEDERATED]));
if (!DBA::isResult($contact)) {
$fields = ['name', 'nick', 'url', 'nurl', 'location', 'about', 'keywords', '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'];
+ 'server_url', 'gsid', 'nsfw', 'hide', 'id'];
$old_gcontact = DBA::selectFirst('gcontact', $fields, ['nurl' => $contact['nurl']]);
$do_insert = !DBA::isResult($old_gcontact);
$gcontact = [];
// These fields are identical in both contact and gcontact
- $fields = ['name', 'nick', 'url', 'nurl', 'location', 'about', 'keywords',
+ $fields = ['name', 'nick', 'url', 'nurl', 'location', 'about', 'keywords', 'gsid',
'contact-type', 'network', 'addr', 'notify', 'alias', 'created', 'updated'];
foreach ($fields as $field) {