mirror of
https://github.com/friendica/friendica
synced 2025-05-02 23:44:23 +02:00
Refactor API notification usage
- Remove "mapFields()" from BaseModel - Add new Notification API entity (including collection) - Add new NotificationFactory method "getApiList()"
This commit is contained in:
parent
4a3544582c
commit
582f6bd4a3
9 changed files with 164 additions and 109 deletions
|
@ -6,6 +6,7 @@ use Exception;
|
|||
use Friendica\App;
|
||||
use Friendica\App\BaseURL;
|
||||
use Friendica\BaseFactory;
|
||||
use Friendica\Collection\Api\Notifications as ApiNotifications;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig\IPConfig;
|
||||
|
@ -15,6 +16,7 @@ use Friendica\Database\Database;
|
|||
use Friendica\Model\Item;
|
||||
use Friendica\Module\BaseNotifications;
|
||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
use Friendica\Object\Api\Friendica\Notification as ApiNotification;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Repository;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
@ -352,4 +354,26 @@ class Notification extends BaseFactory
|
|||
|
||||
return $formattedNotifications;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $uid The user id of the API call
|
||||
* @param array $params Additional parameters
|
||||
*
|
||||
* @return ApiNotifications
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getApiList(int $uid, array $params = ['order' => ['seen' => 'ASC', 'date' => 'DESC'], 'limit' => 50])
|
||||
{
|
||||
$notifies = $this->notification->select(['uid' => $uid], $params);
|
||||
|
||||
/** @var ApiNotification[] $notifications */
|
||||
$notifications = [];
|
||||
|
||||
foreach ($notifies as $notify) {
|
||||
$notifications[] = new ApiNotification($notify);
|
||||
}
|
||||
|
||||
return new ApiNotifications($notifications);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue