common = new Common; $this->count = 20; } public function index ($page=0) { if (!isset($this->common->user['me']) || is_null($this->common->user['me'])) { return redirect('/peertube/login'); } $res = [ 'page' => 'notification', 'style' => 'myaccount', 'paginate' => $page, 'pagetotal' => 500, 'userinfo' => $this->common->user, ]; $res['notification'] = $this->getNotification(($page*$this->count), $this->count); return view('pages.peertube.my-account.notifications', ['res' => $res]); } function getNotification ($start, $count) { return $this->ptapi('/api/v1/users/me/notifications?start='.$start.'&count='.$count.'&sort=-createdAt'); } public function read (Request $r) { $this->ptapi('/api/v1/users/me/notifications/read', json_encode(['ids' => [(int)$r->id]]), 'post'); return redirect('/peertube/my-account/notifications'); } public function readAll () { $this->ptapi('/api/v1/users/me/notifications/read-all', '', 'post'); return redirect('/peertube/my-account/notifications'); } }