- if (empty($fid)) {
- $fields = ['name' => $suggest['name'], 'url' => $suggest['url'],
- 'photo' => $suggest['photo'], 'request' => $suggest['request']];
- DBA::insert('fcontact', $fields);
- $fid = DBA::lastInsertId();
- if (empty($fid)) {
- Logger::warning('FContact had not been created', ['fcontact' => $fields]);
- return false;
- }
- }
-
- $hash = Strings::getRandomHex();
- $fields = ['uid' => $suggest['uid'], 'fid' => $fid, 'contact-id' => $suggest['cid'],
- 'note' => $suggest['body'], 'hash' => $hash, 'datetime' => DateTimeFormat::utcNow(), 'blocked' => false];
- DBA::insert('intro', $fields);
-
- notification(
- [
- 'type' => Type::SUGGEST,
- 'notify_flags' => $owner['notify-flags'],
- 'language' => $owner['language'],
- 'to_name' => $owner['name'],
- 'to_email' => $owner['email'],
- 'uid' => $owner['uid'],
- 'item' => $suggest,
- 'link' => DI::baseUrl().'/notifications/intros',
- 'source_name' => $contact['name'],
- 'source_link' => $contact['url'],
- 'source_photo' => $contact['photo'],
- 'verb' => Activity::REQ_FRIEND,
- 'otype' => 'intro']
- );
-
- return true;