]> git.mxchange.org Git - friendica.git/commitdiff
Removing api_friendica_direct_messages_conversations
authorgerhard6380 <gerhard@seeber.at>
Thu, 11 Aug 2016 21:53:00 +0000 (23:53 +0200)
committergerhard6380 <gerhard@seeber.at>
Thu, 11 Aug 2016 21:53:00 +0000 (23:53 +0200)
due to implementing 'seen' and 'parent-uri' into standard
api_format_messages() this call is not needed anymore. Adapting comment
blocks.

include/api.php

index c60575638a4c5c37b018dfeb59dfdb5b70b7c830..fdaf50e661130fb02496d363d525a26a63290632 100644 (file)
 
 
        /**
-        * @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();
                }
 
 
-               $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();
        /**
         * @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();
        /**
         * @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();
        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