- $r = q("SELECT * FROM `contact` WHERE `subhub` AND `id` = %d AND `uid` = %d
- AND (`rel` = %d OR `rel` = %d OR network = '%s') AND NOT `blocked` LIMIT 1",
- intval($contact_id),
- intval($importer['uid']),
- intval(CONTACT_IS_SHARING),
- intval(CONTACT_IS_FRIEND),
- dbesc(NETWORK_FEED)
- );
+ if (!DBM::is_result($contact)) {
+ $author = OStatus::salmonAuthor($xml, $importer);
+ if (!empty($author['contact-id'])) {
+ $condition = ['id' => $author['contact-id'], 'uid' => $importer['uid'], 'subhub' => true, 'blocked' => false];
+ $contact = dba::selectFirst('contact', [], $condition);
+ logger('No record for ' . $nick .' with contact id ' . $contact_id . ' - using '.$author['contact-id'].' instead.');
+ }
+ if (!DBM::is_result($contact)) {
+ logger('Contact ' . $author["author-link"] . ' (' . $contact_id . ') for user ' . $nick . " wasn't found - ignored. XML: " . $xml);
+ hub_post_return();
+ }
+ }