moved api direct message formating to own function.
added same formating to direct reply message, when posting a new message.
This commit is contained in:
parent
0f0fb2e2f3
commit
587b081a38
|
@ -1238,6 +1238,40 @@
|
|||
return($as);
|
||||
}
|
||||
|
||||
function api_format_messages($item, $recipient, $sender) {
|
||||
// standard meta information
|
||||
$ret=Array(
|
||||
'id' => $item['id'],
|
||||
'created_at' => api_date($item['created']),
|
||||
'sender_id' => $sender['id'] ,
|
||||
'sender_screen_name' => $sender['screen_name'],
|
||||
'sender' => $sender,
|
||||
'recipient_id' => $recipient['id'],
|
||||
'recipient_screen_name' => $recipient['screen_name'],
|
||||
'recipient' => $recipient,
|
||||
);
|
||||
|
||||
//don't send title to regular StatusNET requests to avoid confusing these apps
|
||||
if (x($_GET, 'getText')) {
|
||||
$ret['title'] = $item['title'] ;
|
||||
if ($_GET["getText"] == "html") {
|
||||
$ret['text'] = bbcode($item['body']);
|
||||
}
|
||||
elseif ($_GET["getText"] == "plain") {
|
||||
$ret['text'] = html2plain(bbcode($item['body']), 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$ret['text'] = $item['title']."\n".html2plain(bbcode($item['body']), 0);
|
||||
}
|
||||
if (isset($_GET["getUserObjects"]) && $_GET["getUserObjects"] == "false") {
|
||||
unset($ret['sender']);
|
||||
unset($ret['recipient']);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function api_format_items($r,$user_info) {
|
||||
|
||||
//logger('api_format_items: ' . print_r($r,true));
|
||||
|
@ -1546,20 +1580,7 @@
|
|||
|
||||
if ($id>-1) {
|
||||
$r = q("SELECT * FROM `mail` WHERE id=%d", intval($id));
|
||||
$item = $r[0];
|
||||
$ret=Array(
|
||||
'id' => $item['id'],
|
||||
'created_at'=> api_date($item['created']),
|
||||
'sender_id'=> $sender['id'] ,
|
||||
'sender_screen_name'=> $sender['screen_name'],
|
||||
'sender'=> $sender,
|
||||
'recipient_id'=> $recipient['id'],
|
||||
'recipient_screen_name'=> $recipient['screen_name'],
|
||||
'recipient'=> $recipient,
|
||||
|
||||
'text'=> $item['title']."\n".html2plain(bbcode($item['body']), 0) ,
|
||||
|
||||
);
|
||||
$ret = api_format_messages($r[0], $recipient, $sender);
|
||||
|
||||
} else {
|
||||
$ret = array("error"=>$id);
|
||||
|
@ -1593,11 +1614,14 @@
|
|||
$profile_url = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
|
||||
if ($box=="sentbox") {
|
||||
$sql_extra = "`from-url`='".dbesc( $profile_url )."'";
|
||||
} elseif ($box=="conversation") {
|
||||
}
|
||||
elseif ($box=="conversation") {
|
||||
$sql_extra = "`parent-uri`='".dbesc( $_GET["uri"] ) ."'";
|
||||
} elseif ($box=="all") {
|
||||
}
|
||||
elseif ($box=="all") {
|
||||
$sql_extra = "true";
|
||||
} elseif ($box=="inbox") {
|
||||
}
|
||||
elseif ($box=="inbox") {
|
||||
$sql_extra = "`from-url`!='".dbesc( $profile_url )."'";
|
||||
}
|
||||
|
||||
|
@ -1611,37 +1635,13 @@
|
|||
if ($box == "inbox" || $item['from-url'] != $profile_url){
|
||||
$recipient = $user_info;
|
||||
$sender = api_get_user($a,$item['contact-id']);
|
||||
} elseif ($box == "sentbox" || $item['from-url'] != $profile_url){
|
||||
}
|
||||
elseif ($box == "sentbox" || $item['from-url'] != $profile_url){
|
||||
$recipient = api_get_user($a,$item['contact-id']);
|
||||
$sender = $user_info;
|
||||
}
|
||||
|
||||
$d=Array(
|
||||
'id' => $item['id'],
|
||||
'created_at'=> api_date($item['created']),
|
||||
'sender_id'=> $sender['id'] ,
|
||||
'sender_screen_name'=> $sender['screen_name'],
|
||||
'sender_profile_img'=> $item['from-photo'],
|
||||
'sender'=> $sender,
|
||||
'recipient_id'=> $recipient['id'],
|
||||
'recipient_screen_name'=> $recipient['screen_name'],
|
||||
'recipient'=> $recipient,
|
||||
);
|
||||
//don't send title to regular StatusNET requests to avoid confusing these apps
|
||||
if (isset($_GET["getText"])) {
|
||||
$d['title'] = $item['title'] ;
|
||||
if ($_GET["getText"] == "html") {
|
||||
$d['text'] = bbcode($item['body']);
|
||||
} elseif ($_GET["getText"] == "plain") {
|
||||
$d['text'] = html2plain(bbcode($item['body']), 0);
|
||||
}
|
||||
} else {
|
||||
$d['text'] = $item['title']."\n".html2plain(bbcode($item['body']), 0);
|
||||
}
|
||||
if (isset($_GET["getUserObjects"]) && $_GET["getUserObjects"] == "false") {
|
||||
unset($d['sender']); unset($d['recipient']);
|
||||
}
|
||||
$ret[]=$d;
|
||||
$ret[]=api_format_messages($item, $recipient, $sender);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue