- $r = q("SELECT * FROM `contact` WHERE `network` IN ('%s', '%s')
- AND (`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s')
- AND `uid` = %d LIMIT 1",
- DBA::escape(Protocol::OSTATUS),
- DBA::escape(Protocol::DFRN),
- DBA::escape(normalise_link($author_link)),
- DBA::escape($author_link),
- DBA::escape(normalise_link($author_link)),
- intval($importer['uid'])
- );
-
- if (!DBA::isResult($r)) {
- logger('Author ' . $author_link . ' unknown to user ' . $importer['uid'] . '.');
-
- if (PConfig::get($importer['uid'], 'system', 'ostatus_autofriend')) {
- $result = Contact::createFromProbe($importer['uid'], $author_link);
-
- if ($result['success']) {
- $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s')
- AND `uid` = %d LIMIT 1",
- DBA::escape(Protocol::OSTATUS),
- DBA::escape($author_link),
- DBA::escape($author_link),
- intval($importer['uid'])
- );
- }
- }
+ $contact = DBA::selectFirst('contact', ["`network` IN (?, ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `uid` = ?",
+ Protocol::OSTATUS, Protocol::DFRN, Strings::normaliseLink($author_link), $author_link, Strings::normaliseLink($author_link), $importer['uid']]);
+
+ if (!empty($contact['gsid'])) {
+ GServer::setProtocol($contact['gsid'], Post\DeliveryData::OSTATUS);