aboutsummaryrefslogtreecommitdiffstats
path: root/include/message.php
diff options
context:
space:
mode:
authorzottel <github@zottel.net>2011-12-06 00:02:29 -0800
committerzottel <github@zottel.net>2011-12-06 00:02:29 -0800
commitcd3a02ab8e5aa2dc56ba3939e5d480e4966b11aa (patch)
tree2efc84f14303c5d8dd283a93b64f02851e969e3f /include/message.php
parentc5c99089ff363831f199e27c188410fec682fda5 (diff)
parent47f369e052d296f4a744c1508efc58f6168b7e8b (diff)
downloadvolse-hubzilla-cd3a02ab8e5aa2dc56ba3939e5d480e4966b11aa.tar.gz
volse-hubzilla-cd3a02ab8e5aa2dc56ba3939e5d480e4966b11aa.tar.bz2
volse-hubzilla-cd3a02ab8e5aa2dc56ba3939e5d480e4966b11aa.zip
Merge remote branch 'upstream/master'
Diffstat (limited to 'include/message.php')
-rw-r--r--include/message.php28
1 files changed, 19 insertions, 9 deletions
diff --git a/include/message.php b/include/message.php
index 05157cc83..baf1bb2d5 100644
--- a/include/message.php
+++ b/include/message.php
@@ -27,9 +27,27 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
$hash = random_string();
$uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $hash ;
- if(! strlen($replyto)) {
+ $convid = 0;
+
+ // look for any existing conversation structure
+
+ if(strlen($replyto)) {
+ $r = q("select convid from mail where uid = %d and uri = '%s' limit 1",
+ intval(local_user()),
+ dbesc($replyto)
+ );
+ if(count($r))
+ $convid = $r[0]['convid'];
+ }
+
+ if(! strlen($replyto))
$replyto = $uri;
+
+ if(! $convid) {
+
+ // create a new conversation
+
$conv_guid = get_guid();
$recip_host = substr($contact[0]['url'],strpos($contact[0]['url'],'://')+3);
@@ -52,14 +70,6 @@ function send_message($recipient=0, $body='', $subject='', $replyto=''){
if(count($r))
$convid = $r[0]['id'];
}
- else {
- $r = q("select convid from mail where uid = %d and uri = '%s' limit 1",
- intval(local_user()),
- dbesc($replyto)
- );
- if(count($r))
- $convid = $r[0]['convid'];
- }
if(! $convid) {
logger('send message: conversation not found.');