requireUser(); $res = (object) [ "items" => [], "profiles" => [], "groups" => [], "last_viewed" => $this->getUser()->getNotificationOffset(), ]; if ($count > 100) { $this->fail(125, "Count is too big"); } if (!eventdb()) { $this->fail(1289, "EventDB is disabled on this instance"); } $notifs = array_slice(iterator_to_array((new Notifs())->getNotificationsByUser($this->getUser(), $this->getUser()->getNotificationOffset(), (bool) $archived, 1, $offset + $count)), $offset); $tmpProfiles = []; foreach ($notifs as $notif) { $sxModel = $notif->getModel(1); if (!method_exists($sxModel, "getAvatarUrl")) { $sxModel = $notif->getModel(0); } $tmpProfiles[] = $sxModel instanceof Club ? $sxModel->getId() * -1 : $sxModel->getId(); $res->items[] = $notif->toVkApiStruct(); } foreach (array_unique($tmpProfiles) as $id) { if ($id > 0) { $sxModel = (new Users())->get($id); $result = (object) [ "uid" => $sxModel->getId(), "first_name" => $sxModel->getFirstName(), "last_name" => $sxModel->getLastName(), "photo" => $sxModel->getAvatarUrl(), "photo_medium_rec" => $sxModel->getAvatarUrl("tiny"), "screen_name" => $sxModel->getShortCode(), ]; $res->profiles[] = $result; } else { $sxModel = (new Clubs())->get(abs($id)); $result = $sxModel->toVkApiStruct($this->getUser()); $res->groups[] = $result; } } return $res; } public function markAsViewed() { $this->requireUser(); $this->willExecuteWriteAction(); try { $this->getUser()->updateNotificationOffset(); $this->getUser()->save(); } catch (\Throwable $e) { return 0; } return 1; } }