]> _ Git - psq.git/commitdiff
add env to email tags
authorLouis Jeckel <louis.jeckel@outlook.cm>
Tue, 14 Apr 2020 14:23:50 +0000 (16:23 +0200)
committerLouis Jeckel <louis.jeckel@outlook.cm>
Tue, 14 Apr 2020 14:23:50 +0000 (16:23 +0200)
app/Events/ProcessMailgunWebhook.php
app/Jobs/ProcessEmailBatch.php
app/Providers/HorizonServiceProvider.php

index 6e657d91bc56d0caa799c4ed9608da7cb57973be..9346d65546fe7a92f916fe7f383a368132c3e54e 100644 (file)
@@ -26,6 +26,8 @@ class ProcessMailgunWebhook implements ShouldBroadcast
 
     public $data;
 
+    private $broadcast;
+
 
     /**
      * Create a new event instance.
@@ -36,6 +38,9 @@ class ProcessMailgunWebhook implements ShouldBroadcast
     {
         $tags = Arr::get($webhookData, 'event-data.tags');
 
+        $broadcast = in_array(env('APP_ENV'), $tags, true);
+
+
         /** @todo check webhook key */
 
         $this->batch_id = Str::after(Arr::first($tags, function($tag) {
@@ -63,6 +68,11 @@ class ProcessMailgunWebhook implements ShouldBroadcast
         return new PrivateChannel('emailBatch.'.$this->batch_id);
     }
 
+    public function broadcastWhen()
+    {
+        return $this->broadcast;
+    }
+
     /**
      * The event's broadcast name.
      */
index 5b81529e25772269fca88e07e7c9d511ae767567..59e0a0ce05397713deb7d8618308ca1f467e2d39 100644 (file)
@@ -83,7 +83,7 @@ class ProcessEmailBatch implements ShouldQueue
                 'subject' => $this->batch->subject,
                 'recipient-variables' => $variables,
                 'html' => $view,
-                'o:tag' => [$this->batch->getTag(), 'psq'],
+                'o:tag' => [$this->batch->getTag(), 'psq', env('APP_ENV')],
                 'o:testmode' => env('MAILGUN_TEST_MODE', 'yes'),
             ];
 
index 45ccba340b3441fe400d6857b0386f1a848f2df5..0ef1ae529686d80cc22ce9728d3d06f8b8275d0a 100644 (file)
@@ -34,7 +34,7 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider
      */
     protected function gate()
     {
-        Gate::define('viewHorizon', function ($user) {
+        Gate::define('viewHorizon', function ($user = null) {
             return true;
         });
     }