diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/api.php | 4 | ||||
-rw-r--r-- | include/message.php | 28 | ||||
-rw-r--r-- | include/text.php | 4 |
3 files changed, 23 insertions, 13 deletions
diff --git a/include/api.php b/include/api.php index 1196e0aac..9cf4551bd 100644 --- a/include/api.php +++ b/include/api.php @@ -296,7 +296,7 @@ // count friends $r = q("SELECT COUNT(`id`) as `count` FROM `contact` WHERE `uid` = %d AND `rel` IN ( %d, %d ) - AND `self`=0 AND `blocked`=0", + AND `self`=0 AND `blocked`=0 AND `pending`=0 AND `hidden`=0", intval($uinfo[0]['uid']), intval(CONTACT_IS_SHARING), intval(CONTACT_IS_FRIEND) @@ -305,7 +305,7 @@ $r = q("SELECT COUNT(`id`) as `count` FROM `contact` WHERE `uid` = %d AND `rel` IN ( %d, %d ) - AND `self`=0 AND `blocked`=0", + AND `self`=0 AND `blocked`=0 AND `pending`=0 AND `hidden`=0", intval($uinfo[0]['uid']), intval(CONTACT_IS_FOLLOWER), intval(CONTACT_IS_FRIEND) 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.'); diff --git a/include/text.php b/include/text.php index c4fd76e3e..29e53c663 100644 --- a/include/text.php +++ b/include/text.php @@ -539,7 +539,7 @@ function contact_block() { if((! is_array($a->profile)) || ($a->profile['hide-friends'])) return $o; - $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0", + $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0", intval($a->profile['uid']) ); if(count($r)) { @@ -550,7 +550,7 @@ function contact_block() { $micropro = Null; } else { - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 ORDER BY RAND() LIMIT %d", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 ORDER BY RAND() LIMIT %d", intval($a->profile['uid']), intval($shown) ); |