$fields = array('uid' => local_user(), 'guid' => $conv_guid, 'creator' => $sender_handle,
'created' => datetime_convert(), 'updated' => datetime_convert(),
'subject' => $subject, 'recips' => $handles);
- dba::insert('conv', $fields);
- $convid = dba::lastInsertId();
+ if (dba::insert('conv', $fields)) {
+ $convid = dba::lastInsertId();
+ }
}
if (!$convid) {
$replyto = $convuri;
}
- q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`,
+ $post_id = null;
+ $result = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`,
`contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`)
VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s' )",
intval(local_user()),
dbesc($replyto),
datetime_convert()
);
- $post_id = dba::lastInsertId();
+ if ($result) {
+ $post_id = dba::lastInsertId();
+ }
/**
*
$handles = $recip_handle . ';' . $sender_handle;
+ $convid = null;
$fields = array('uid' => $recipient['uid'], 'guid' => $conv_guid, 'creator' => $sender_handle,
'created' => datetime_convert(), 'updated' => datetime_convert(),
'subject' => $subject, 'recips' => $handles);
- dba::insert('conv', $fields);
- $convid = dba::lastInsertId();
+ if (dba::insert('conv', $fields)) {
+ $convid = dba::lastInsertId();
+ }
if (!$convid) {
logger('send message: conversation not found.');