← All changes
|
app/Features/Notifications/NotificationsController.php
+12
-3
2.0.2
→
2.1.1
View file →
| @@ -9,28 +9,37 @@ | ||
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | use Metricool\Interfaces\FeatureInterface; |
| 12 | 12 | use Metricool\Interfaces\NoticeInterface; |
| 13 | +use Metricool\Services\DashboardService; | |
| 14 | +use Metricool\Traits\HasAllowlistControl; | |
| 13 | 15 | |
| 14 | 16 | class NotificationsController implements FeatureInterface |
| 15 | 17 | { |
| 18 | + use HasAllowlistControl; | |
| 19 | + | |
| 16 | 20 | private NotificationsEndpoints $endpoints; |
| 17 | 21 | private NotificationsService $service; |
| 18 | 22 | private NotificationListener $listener; |
| 23 | + private DashboardService $dashboard; | |
| 19 | 24 | |
| 20 | - public function __construct(NotificationsEndpoints $endpoints, NotificationsService $service, NotificationListener $listener) | |
| 25 | + public function __construct(NotificationsEndpoints $endpoints, NotificationsService $service, NotificationListener $listener, DashboardService $dashboard) | |
| 21 | 26 | { |
| 22 | 27 | $this->service = $service; |
| 23 | 28 | $this->endpoints = $endpoints; |
| 24 | 29 | $this->listener = $listener; |
| 30 | + $this->dashboard = $dashboard; | |
| 25 | 31 | } |
| 26 | 32 | |
| 27 | 33 | public function register(): void |
| 28 | 34 | { |
| 29 | 35 | $this->endpoints->register(); |
| 30 | - $this->listener->listen(); | |
| 31 | 36 | |
| 32 | - $this->initiateNotices(); | |
| 37 | + if ($this->userCanManage() && $this->dashboard->isOnboardingCompleted()) { | |
| 38 | + $this->listener->listen(); | |
| 39 | + $this->initiateNotices(); | |
| 40 | + } | |
| 41 | + | |
| 33 | 42 | add_action('metricool_plugin_version_upgrade', [$this, 'upgradeNotices']); |
| 34 | 43 | } |
| 35 | 44 | |
| 36 | 45 | /** |