diff --git a/include/api.php b/include/api.php index 11950f52f3..41d1e2f1e8 100644 --- a/include/api.php +++ b/include/api.php @@ -5590,7 +5590,7 @@ function api_friendica_notification($type) throw new BadRequestException('Invalid argument count'); } - $Notifies = DI::notify()->selectAllForUser(local_user(), ['order' => ['seen' => 'ASC', 'date' => 'DESC'], 'limit' => 50]); + $Notifies = DI::notify()->selectAllForUser(local_user(), 50); $notifications = new ApiNotifications(); foreach ($Notifies as $Notify) { diff --git a/src/Navigation/Notifications/Depository/Notify.php b/src/Navigation/Notifications/Depository/Notify.php index c35f50a73b..4c7a1ef33d 100644 --- a/src/Navigation/Notifications/Depository/Notify.php +++ b/src/Navigation/Notifications/Depository/Notify.php @@ -73,9 +73,16 @@ class Notify extends BaseDepository return $this->select($condition, $params); } - public function selectAllForUser(int $uid, array $params = []): Collection\Notifies + /** + * Returns notifications for the user, unread first, ordered in descending chronological order. + * + * @param int $uid + * @param int $limit + * @return Collection\Notifies + */ + public function selectAllForUser(int $uid, int $limit): Collection\Notifies { - return $this->selectForUser($uid, [], $params); + return $this->selectForUser($uid, [], ['order' => ['seen' => 'ASC', 'date' => 'DESC'], 'limit' => $limit]); } public function setAllSeenForUser(int $uid, array $condition = []): bool