X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fmessage.php;h=7ad80ae9c61f23ea42212e42289c2164e8bc132c;hb=e55d13c2b4425183dde64da8ca27c794f4c04900;hp=58789d6884a0f9b1ba5866e9e4eab26cb0d2cd4c;hpb=be8e9d36160d8a45bb11c3ab9ecdbf0c4f5cdf7d;p=friendica.git diff --git a/include/message.php b/include/message.php old mode 100644 new mode 100755 index 58789d6884..7ad80ae9c6 --- a/include/message.php +++ b/include/message.php @@ -5,6 +5,7 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){ + $a = get_app(); if(! $recipient) return -1; @@ -28,22 +29,21 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){ $uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $hash ; $convid = 0; + $reply = false; // look for any existing conversation structure if(strlen($replyto)) { - $r = q("select convid from mail where uid = %d and uri = '%s' limit 1", + $reply = true; + $r = q("select convid from mail where uid = %d and ( uri = '%s' or `parent-uri` = '%s' ) limit 1", intval(local_user()), + dbesc($replyto), dbesc($replyto) ); if(count($r)) $convid = $r[0]['convid']; } - if(! strlen($replyto)) - $replyto = $uri; - - if(! $convid) { // create a new conversation @@ -81,9 +81,14 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){ return -4; } + if(! strlen($replyto)) { + $replyto = $uri; + } + + $r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`, - `contact-id`, `title`, `body`, `seen`, `replied`, `uri`, `parent-uri`, `created`) - VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, '%s', '%s', '%s' )", + `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(get_guid()), intval($convid), @@ -94,11 +99,14 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){ dbesc($subject), dbesc($body), 1, + intval($reply), 0, dbesc($uri), dbesc($replyto), datetime_convert() ); + + $r = q("SELECT * FROM `mail` WHERE `uri` = '%s' and `uid` = %d LIMIT 1", dbesc($uri), intval(local_user())