X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fapi.php;h=0729c2a0f89c88712bd4a3e329c3c44596a25d7a;hb=b85511b00db778030302255fd6901157c750a2f1;hp=cb0599d9a6b0b1294de3d62044bf4703e58b3b62;hpb=0850fb88dd82d53bd12b8d2850107a5ef07f9473;p=friendica.git diff --git a/include/api.php b/include/api.php index cb0599d9a6..0729c2a0f8 100644 --- a/include/api.php +++ b/include/api.php @@ -23,6 +23,7 @@ use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\Item; use Friendica\Model\Mail; +use Friendica\Model\Notification; use Friendica\Model\Photo; use Friendica\Model\Profile; use Friendica\Model\User; @@ -5906,19 +5907,24 @@ function api_friendica_notification($type) throw new BadRequestException("Invalid argument count"); } - $notifications = DI::notification()->select([], ['order' => ['seen' => 'ASC', 'date' => 'DESC'], 'limit' => 50]); + $notifications = DI::notification()->select(['uid' => api_user()], ['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]); } /** @@ -5952,8 +5958,7 @@ function api_friendica_notification_seen($type) $notification = DI::notification()->getByID($id); $notification->setSeen(); - if ($notification->otype == 'item') { - // would be really better with an ItemsManager and $im->getByID() :-P + if ($notification->otype === Notification::OTYPE_ITEM) { $item = Item::selectFirstForUser(api_user(), [], ['id' => $notification->iid, 'uid' => api_user()]); if (DBA::isResult($item)) { // we found the item, return it to the user