3 namespace Friendica\Repository;
6 use Friendica\BaseRepository;
7 use Friendica\Core\Hook;
9 use Friendica\Collection;
10 use Friendica\Network\HTTPException\NotFoundException;
11 use Friendica\Util\DateTimeFormat;
13 class Notify extends BaseRepository
15 protected static $table_name = 'notify';
17 protected static $model_class = Model\Notify::class;
19 protected static $collection_class = Collection\Notifies::class;
24 * @return Model\Notify
26 protected function create(array $data)
28 return new Model\Notify($this->dba, $this->logger, $this, $data);
34 * @return Collection\Notifies
36 public function select(array $condition = [], array $params = [])
38 $params['order'] = $params['order'] ?? ['date' => 'DESC'];
40 return parent::select($condition, $params);
46 * @return Model\Notify
47 * @throws NotFoundException
49 public function getByID(int $id)
51 return $this->selectFirst(['id' => $id, 'uid' => local_user()]);
57 * @return bool true on success, false on error
60 public function setAllSeen(bool $seen = true)
62 return $this->dba->update('notify', ['seen' => $seen], ['uid' => local_user()]);
66 * @param array $fields
68 * @return Model\Notify|false
70 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
73 public function insert(array $fields)
75 $fields['date'] = DateTimeFormat::utcNow();
77 Hook::callAll('enotify_store', $fields);
80 $this->logger->debug('Abort adding notification entry');
84 $this->logger->debug('adding notification entry', ['fields' => $fields]);
86 return parent::insert($fields);