aboutsummaryrefslogtreecommitdiffstats
path: root/include/api.php
diff options
context:
space:
mode:
authoranaqreon <tamanning@zoho.com>2014-12-30 16:06:35 -0600
committeranaqreon <tamanning@zoho.com>2014-12-30 16:06:35 -0600
commitb78a545a1056e6db9f4b6b4f262182b0a5c56e67 (patch)
tree515c2f742a5a39e18b00debf1849ee9703fa4a42 /include/api.php
parentd67c5a6ffd134602084a6dcb37b316bf768bf715 (diff)
parent43671a0a323afa758df56c06822ce3c46da026df (diff)
downloadvolse-hubzilla-b78a545a1056e6db9f4b6b4f262182b0a5c56e67.tar.gz
volse-hubzilla-b78a545a1056e6db9f4b6b4f262182b0a5c56e67.tar.bz2
volse-hubzilla-b78a545a1056e6db9f4b6b4f262182b0a5c56e67.zip
Merge pull request #1 from friendica/master
Pull from upstream
Diffstat (limited to 'include/api.php')
-rw-r--r--include/api.php26
1 files changed, 16 insertions, 10 deletions
diff --git a/include/api.php b/include/api.php
index aeee95d3b..51de412cf 100644
--- a/include/api.php
+++ b/include/api.php
@@ -1868,11 +1868,14 @@ require_once('include/items.php');
require_once("include/message.php");
- $r = q("SELECT `id` FROM `contact` WHERE `uid`=%d AND `nick`='%s'",
+ // in a decentralised world the screen name is ambiguous
+
+ $r = q("SELECT `abook_id` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE `abook_channel`=%d and xchan_addr like '%s'",
intval(api_user()),
- dbesc($_POST['screen_name']));
+ dbesc($_POST['screen_name'] . '@%')
+ );
- $recipient = api_get_user($a, $r[0]['id']);
+ $recipient = api_get_user($a, $r[0]['abook_id']);
$replyto = '';
$sub = '';
if (x($_REQUEST,'replyto')) {
@@ -1925,10 +1928,11 @@ require_once('include/items.php');
if ($page<0) $page=0;
$start = $page*$count;
-
- $profile_url = $a->get_baseurl() . '/channel/' . $a->user['nickname'];
+ $channel = $a->get_channel();
+
+ $profile_url = $a->get_baseurl() . '/channel/' . $channel['channel_address'];
if ($box=="sentbox") {
- $sql_extra = "`from-url`='".dbesc( $profile_url )."'";
+ $sql_extra = "`from_xchan`='".dbesc( $channel['channel_hash'] )."'";
}
elseif ($box=="conversation") {
$sql_extra = "`parent_mid`='".dbesc( $_GET["uri"] ) ."'";
@@ -1937,10 +1941,10 @@ require_once('include/items.php');
$sql_extra = "true";
}
elseif ($box=="inbox") {
- $sql_extra = "`from-url`!='".dbesc( $profile_url )."'";
+ $sql_extra = "`from_xchan`!='".dbesc( $channel['channel_hash'] )."'";
}
- $r = q("SELECT * FROM `mail` WHERE uid=%d AND $sql_extra ORDER BY created DESC LIMIT %d OFFSET %d",
+ $r = q("SELECT * FROM `mail` WHERE channel_id = %d AND $sql_extra ORDER BY created DESC LIMIT %d OFFSET %d",
intval(api_user()),
intval($count), intval($start)
);
@@ -1950,10 +1954,12 @@ require_once('include/items.php');
foreach($r as $item) {
if ($box == "inbox" || $item['from-url'] != $profile_url){
$recipient = $user_info;
- $sender = api_get_user($a,$item['contact-id']);
+ // fixme to lookup recipient
+ $sender = api_get_user($a);
}
elseif ($box == "sentbox" || $item['from-url'] != $profile_url){
- $recipient = api_get_user($a,$item['contact-id']);
+ // fixme to lookup recipient
+ $recipient = api_get_user($a);
$sender = $user_info;
}