- DBA::lock('mail');
-
- if (DBA::exists('mail', ['guid' => $msg_guid, 'uid' => $importer["uid"]])) {
- Logger::log("duplicate message already delivered.", LOGGER_DEBUG);
- return false;
- }
-
- q(
- "INSERT INTO `mail` (`uid`, `guid`, `convid`, `from-name`,`from-photo`,`from-url`,`contact-id`,`title`,`body`,`seen`,`reply`,`uri`,`parent-uri`,`created`)
- VALUES (%d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, '%s','%s','%s')",
- intval($importer["uid"]),
- DBA::escape($msg_guid),
- intval($conversation["id"]),
- DBA::escape($person["name"]),
- DBA::escape($person["photo"]),
- DBA::escape($person["url"]),
- intval($contact["id"]),
- DBA::escape($subject),
- DBA::escape($body),
- 0,
- 0,
- DBA::escape($message_uri),
- DBA::escape($author.":".$guid),
- DBA::escape($msg_created_at)
- );
-
- DBA::unlock();
-
- DBA::update('conv', ['updated' => DateTimeFormat::utcNow()], ['id' => $conversation["id"]]);
-
- notification(
- [
- "type" => NOTIFY_MAIL,
- "notify_flags" => $importer["notify-flags"],
- "language" => $importer["language"],
- "to_name" => $importer["username"],
- "to_email" => $importer["email"],
- "uid" =>$importer["uid"],
- "item" => ["id" => $conversation["id"], "title" => $subject, "subject" => $subject, "body" => $body],
- "source_name" => $person["name"],
- "source_link" => $person["url"],
- "source_photo" => $person["photo"],
- "verb" => ACTIVITY_POST,
- "otype" => "mail"]
- );
- return true;
+ return Mail::insert([
+ 'uid' => $importer['uid'],
+ 'guid' => $msg_guid,
+ 'convid' => $conversation['id'],
+ 'from-name' => $person['name'],
+ 'from-photo' => $person['photo'],
+ 'from-url' => $person['url'],
+ 'contact-id' => $contact['id'],
+ 'title' => $subject,
+ 'body' => $body,
+ 'uri' => $message_uri,
+ 'parent-uri' => $author . ':' . $guid,
+ 'created' => $msg_created_at
+ ]);