Removing api_friendica_direct_messages_conversations
due to implementing 'seen' and 'parent-uri' into standard api_format_messages() this call is not needed anymore. Adapting comment blocks.
This commit is contained in:
parent
f99a646328
commit
f9f1825e33
108
include/api.php
108
include/api.php
|
@ -3668,12 +3668,11 @@
|
|||
|
||||
|
||||
/**
|
||||
* @brief return direct_messages for Windows 10 App (similar to direct_messages/all, but seen
|
||||
* and parent-uri added to output
|
||||
* @brief return direct_messages (similar to direct_messages/all, but additional
|
||||
* error string returned if no mails available to react in client with notification)
|
||||
*
|
||||
* @param App $a
|
||||
* @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
|
||||
* @return string
|
||||
* @return string (error -> No Mails available, success -> return messages)
|
||||
*/
|
||||
function api_friendica_direct_messages_all($type){
|
||||
$a = get_app();
|
||||
|
@ -3744,25 +3743,24 @@
|
|||
}
|
||||
|
||||
|
||||
$data = array('$messages' => $ret);
|
||||
$data = array('direct-messages' => $ret);
|
||||
switch($type){
|
||||
case "atom":
|
||||
case "rss":
|
||||
$data = api_rss_extra($a, $data, $user_info);
|
||||
}
|
||||
|
||||
return api_format_data("direct_messages_all", $type, $data);
|
||||
return api_format_data("direct-messages", $type, $data);
|
||||
|
||||
}
|
||||
api_register_func('api/friendica/direct_messages_all', 'api_friendica_direct_messages_all', true);
|
||||
|
||||
|
||||
/**
|
||||
* @brief update a direct_message to seen state for Windows 10 App
|
||||
* @brief update a direct_message to seen state
|
||||
*
|
||||
* @param App $a
|
||||
* @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
|
||||
* @return string
|
||||
* @return string (success result=ok, error result=error with error message)
|
||||
*/
|
||||
function api_friendica_direct_messages_setseen($type){
|
||||
$a = get_app();
|
||||
|
@ -3809,9 +3807,8 @@
|
|||
/**
|
||||
* @brief delete a direct_message from mail table through api
|
||||
*
|
||||
* @param App $a
|
||||
* @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
|
||||
* @return string
|
||||
* @return string (success result=ok, error result=error with error message)
|
||||
*/
|
||||
function api_friendica_direct_messages_delete($type){
|
||||
$a = get_app();
|
||||
|
@ -3862,9 +3859,10 @@
|
|||
/**
|
||||
* @brief search for direct_messages containing a searchstring through api
|
||||
*
|
||||
* @param App $a
|
||||
* @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
|
||||
* @return string
|
||||
* @return string (success: success=true if found and search_result contains found messages
|
||||
* success=false if nothing was found, search_result='nothing found',
|
||||
* error: result=error with error message)
|
||||
*/
|
||||
function api_friendica_direct_messages_search($type){
|
||||
$a = get_app();
|
||||
|
@ -3913,90 +3911,6 @@
|
|||
api_register_func('api/friendica/direct_messages_search', 'api_friendica_direct_messages_search', true);
|
||||
|
||||
|
||||
/**
|
||||
* @brief returns all messages for a specified parenturi, similar to api/direct_messages/conversation but enhanced to return parenturi and seen state
|
||||
*
|
||||
* @param App $a
|
||||
* @param string $type Known types are 'atom', 'rss', 'xml' and 'json'
|
||||
* @return string
|
||||
*/
|
||||
function api_friendica_direct_messages_conversation($type) {
|
||||
$a = get_app();
|
||||
if (api_user()===false) return false;
|
||||
|
||||
// params
|
||||
$count = (x($_GET,'count')?$_GET['count']:20);
|
||||
$page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
|
||||
if ($page<0) $page=0;
|
||||
|
||||
$since_id = (x($_REQUEST,'since_id')?$_REQUEST['since_id']:0);
|
||||
$max_id = (x($_REQUEST,'max_id')?$_REQUEST['max_id']:0);
|
||||
|
||||
$user_id = (x($_REQUEST,'user_id')?$_REQUEST['user_id']:"");
|
||||
$screen_name = (x($_REQUEST,'screen_name')?$_REQUEST['screen_name']:"");
|
||||
|
||||
// caller user info
|
||||
unset($_REQUEST["user_id"]);
|
||||
unset($_GET["user_id"]);
|
||||
|
||||
unset($_REQUEST["screen_name"]);
|
||||
unset($_GET["screen_name"]);
|
||||
|
||||
$user_info = api_get_user($a);
|
||||
$profile_url = $user_info["url"];
|
||||
|
||||
|
||||
// pagination
|
||||
$start = $page*$count;
|
||||
|
||||
$sql_extra = "`mail`.`parent-uri`='".dbesc( $_GET["uri"] ) ."'";
|
||||
|
||||
if ($max_id > 0)
|
||||
$sql_extra .= ' AND `mail`.`id` <= '.intval($max_id);
|
||||
|
||||
if ($user_id !="") {
|
||||
$sql_extra .= ' AND `mail`.`contact-id` = ' . intval($user_id);
|
||||
}
|
||||
elseif($screen_name !=""){
|
||||
$sql_extra .= " AND `contact`.`nick` = '" . dbesc($screen_name). "'";
|
||||
}
|
||||
|
||||
$r = q("SELECT `mail`.*, `contact`.`nurl` AS `contact-url` FROM `mail`,`contact` WHERE `mail`.`contact-id` = `contact`.`id` AND `mail`.`uid`=%d AND $sql_extra AND `mail`.`id` > %d ORDER BY `mail`.`id` DESC LIMIT %d,%d",
|
||||
intval(api_user()),
|
||||
intval($since_id),
|
||||
intval($start), intval($count)
|
||||
);
|
||||
|
||||
|
||||
$ret = Array();
|
||||
foreach($r as $item) {
|
||||
if ($box == "inbox" || $item['from-url'] != $profile_url){
|
||||
$recipient = $user_info;
|
||||
$sender = api_get_user($a,normalise_link($item['contact-url']));
|
||||
}
|
||||
elseif ($box == "sentbox" || $item['from-url'] == $profile_url){
|
||||
$recipient = api_get_user($a,normalise_link($item['contact-url']));
|
||||
$sender = $user_info;
|
||||
|
||||
}
|
||||
$ret[]=api_format_messages($item, $recipient, $sender);
|
||||
}
|
||||
|
||||
|
||||
$data = array('$messages' => $ret);
|
||||
switch($type){
|
||||
case "atom":
|
||||
case "rss":
|
||||
$data = api_rss_extra($a, $data, $user_info);
|
||||
}
|
||||
|
||||
return api_format_data("direct_messages", $type, $data);
|
||||
|
||||
}
|
||||
|
||||
api_register_func('api/friendica/direct_messages_conversation','api_friendica_direct_messages_conversation',true);
|
||||
|
||||
|
||||
/*
|
||||
To.Do:
|
||||
[pagename] => api/1.1/statuses/lookup.json
|
||||
|
|
Loading…
Reference in New Issue
Block a user