Switch data source from notify to notification in Module\Notifications\Ping

- Change unused FormattedNotification classes to FormattedNavNotification classes
This commit is contained in:
Hypolite Petovan 2022-03-05 15:34:09 -05:00
parent 1ae7cac236
commit 49971b1465
7 changed files with 299 additions and 627 deletions

View file

@ -100,6 +100,36 @@ class Notification extends BaseRepository
return $this->select($condition, $params);
}
/**
* Returns only the most recent notifications for the same conversation or contact
*
* @param int $uid
* @return Collection\Notifications
* @throws Exception
*/
public function selectDigestForUser(int $uid): Collection\Notifications
{
$rows = $this->db->p("
SELECT notification.*
FROM notification
WHERE id IN (
SELECT MAX(`id`)
FROM notification
WHERE uid = ?
GROUP BY IFNULL(`parent-uri-id`, `actor-id`)
)
ORDER BY `seen`, `id` DESC
LIMIT 50
", $uid);
$Entities = new Collection\Notifications();
foreach ($rows as $fields) {
$Entities[] = $this->factory->createFromTableRow($fields);
}
return $Entities;
}
public function selectAllForUser(int $uid): Collection\Notifications
{
return $this->selectForUser($uid);