Browse Source

Prevent pulse crash when it is not configured

Anil Kulkarni 5 months ago
parent
commit
972b299025
1 changed files with 14 additions and 12 deletions
  1. 14 12
      app/Providers/AppServiceProvider.php

+ 14 - 12
app/Providers/AppServiceProvider.php

@@ -74,19 +74,21 @@ class AppServiceProvider extends ServiceProvider
             return $user->is_admin === 1;
         });
 
-        Pulse::user(function ($user) {
-            $acct = AccountService::get($user->profile_id, true);
+        if (config('pulse.enabled', false)) {
+            Pulse::user(function ($user) {
+                $acct = AccountService::get($user->profile_id, true);
 
-            return $acct ? [
-                'name' => $acct['username'],
-                'extra' => $user->email,
-                'avatar' => $acct['avatar'],
-            ] : [
-                'name' => $user->username,
-                'extra' => 'DELETED',
-                'avatar' => '/storage/avatars/default.jpg',
-            ];
-        });
+                return $acct ? [
+                    'name' => $acct['username'],
+                    'extra' => $user->email,
+                    'avatar' => $acct['avatar'],
+                ] : [
+                    'name' => $user->username,
+                    'extra' => 'DELETED',
+                    'avatar' => '/storage/avatars/default.jpg',
+                ];
+            });
+        }
 
         RateLimiter::for('app-signup', function (Request $request) {
             return Limit::perDay(10)->by($request->ip());