]> git.mxchange.org Git - friendica.git/commitdiff
Simplify Depository\Notify->selectAllForUser parameters
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 19 Sep 2021 16:57:16 +0000 (12:57 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sat, 2 Oct 2021 22:15:45 +0000 (18:15 -0400)
- Shifts database structure knowledge from the controller to the depository where it should be

include/api.php
src/Navigation/Notifications/Depository/Notify.php

index 11950f52f3cbf4d3a20cc05f2f4af1d77e8fc0c4..41d1e2f1e8e96a73083b729dab3a274916c79a7f 100644 (file)
@@ -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) {
index c35f50a73b677f2868e6aafde7cbecd49b085fbf..4c7a1ef33dde5fc29df2543ab842b542c37c4c9b 100644 (file)
@@ -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