]> git.mxchange.org Git - friendica.git/commitdiff
api: favorite create/destroy update also thread table
authorfabrixxm <fabrix.xm@gmail.com>
Wed, 31 Dec 2014 17:08:11 +0000 (18:08 +0100)
committerfabrixxm <fabrix.xm@gmail.com>
Wed, 31 Dec 2014 17:08:11 +0000 (18:08 +0100)
include/api.php

index bacbd65338162fb7be99e168113214a11de8d978..e5711914fe6ad20d10fc7665be64c7904de44fdd 100644 (file)
                } else {
                        $itemid = intval($_REQUEST['id']);
                }
-               if ($action!="create" && $action!="destroy") die(api_error($a, $type, t("Invalid action. ".$action)));
 
                $item = q("SELECT * FROM item WHERE id=%d AND uid=%d",
                                $itemid, api_user());
 
                switch($action){
                        case "create":
-                               $r = q("UPDATE item SET starred=1 WHERE id=%d AND uid=%d",
-                                               $itemid, api_user());
                                $item[0]['starred']=1;
                                break;
                        case "destroy":
-                               $r = q("UPDATE item SET starred=0 WHERE id=%d AND uid=%d",
-                                               $itemid, api_user());
                                $item[0]['starred']=0;
                                break;
+                       default:
+                               die(api_error($a, $type, t("Invalid action. ".$action)));
                }
+               $r = q("UPDATE item SET starred=%d WHERE id=%d AND uid=%d",
+                               $item[0]['starred'], $itemid, api_user());
+
+               q("UPDATE thread SET starred=%d WHERE iid=%d AND uid=%d",
+                       $item[0]['starred'], $itemid, api_user());
 
                if ($r===false) die(api_error($a, $type, t("DB error")));
 
                                $data = api_rss_extra($a, $data, $user_info);
                }
 
-               return  api_apply_template("status", $type, $data);
+               return api_apply_template("status", $type, $data);
        }
 
        api_register_func('api/favorites/create', 'api_favorites_create_destroy', true);