]> git.mxchange.org Git - friendica.git/blobdiff - include/api.php
Fix API result, add PHPDoc and cleanup object construction
[friendica.git] / include / api.php
index cb0599d9a6b0b1294de3d62044bf4703e58b3b62..4a55c2b919ffd89e5517a4e0fd0a385581cc7f8e 100644 (file)
@@ -5909,16 +5909,21 @@ function api_friendica_notification($type)
        $notifications = DI::notification()->select([], ['order' => ['seen' => 'ASC', 'date' => 'DESC'], 'limit' => 50]);
 
        if ($type == "xml") {
-               $xmlnotes = [];
+               $xmlnotes = false;
                if (!empty($notifications)) {
                        foreach ($notifications as $notification) {
                                $xmlnotes[] = ["@attributes" => $notification->toArray()];
                        }
                }
 
-               $notifications = $xmlnotes;
+               $result = $xmlnotes;
+       } elseif (count($notifications) > 0) {
+               $result = $notifications->getArrayCopy();
+       } else {
+               $result = false;
        }
-       return api_format_data("notes", $type, ['note' => $notifications->getArrayCopy()]);
+
+       return api_format_data("notes", $type, ['note' => $result]);
 }
 
 /**