| | |
| | | <?php |
| | | namespace JVBase\rest\routes; |
| | | |
| | | use JVBase\Instance; |
| | | use JVBase\managers\Cache; |
| | | use JVBase\managers\CustomTable; |
| | | use JVBase\registrar\Registrar; |
| | |
| | | */ |
| | | class NotificationsRoutes extends Rest |
| | | { |
| | | use Instance; |
| | | protected int $user_id; |
| | | protected array $notification_types = []; |
| | | protected object $manager; |
| | |
| | | $this->cacheName = 'notifications'; |
| | | $this->cacheTtl = HOUR_IN_SECONDS; |
| | | parent::__construct(); |
| | | |
| | | // Connect notifications cache to user cache |
| | | // When user data changes, notification cache should invalidate |
| | | $this->cache->connect('user'); |
| | | $this->cache = Cache::for($this->cacheName, 'user', $this->cacheTtl); |
| | | |
| | | $this->notifications = CustomTable::for('notifications'); |
| | | $this->metrics = CustomTable::for('notification_metrics'); |
| | |
| | | */ |
| | | public function init(): void |
| | | { |
| | | $this->manager = JVB()->notification(); |
| | | $this->manager = NotificationManager::getInstance(); |
| | | $this->notification_types = $this->manager->getNotificationTypes(true); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | if (!empty($queueData)) { |
| | | JVB()->queue()->queueOperation( |
| | | Queue::getInstance()->queueOperation( |
| | | 'notification_' . $action, |
| | | $args['user_id'], |
| | | $queueData |