瀏覽代碼

Initial rules beta

Will 5 年之前
父節點
當前提交
f5b05dbe8d

+ 3 - 22
app/Console/Commands/ReceiveEmail.php

@@ -162,16 +162,11 @@ class ReceiveEmail extends Command
         if ($alias) {
             $sendTo = Str::replaceLast('=', '@', $recipient['extension']);
 
-            $emailData = new EmailData($this->parser);
+            $emailData = new EmailData($this->parser, $this->size);
 
             $message = new ReplyToEmail($user, $alias, $emailData);
 
             Mail::to($sendTo)->queue($message);
-
-            $alias->increment('emails_replied');
-
-            $user->bandwidth += $this->size;
-            $user->save();
         }
     }
 
@@ -195,18 +190,11 @@ class ReceiveEmail extends Command
 
         $sendTo = Str::replaceLast('=', '@', $recipient['extension']);
 
-        $emailData = new EmailData($this->parser);
+        $emailData = new EmailData($this->parser, $this->size);
 
         $message = new SendFromEmail($user, $alias, $emailData);
 
         Mail::to($sendTo)->queue($message);
-
-        if (!Mail::failures()) {
-            $alias->increment('emails_sent');
-
-            $user->bandwidth += $this->size;
-            $user->save();
-        }
     }
 
     protected function handleForward($user, $recipient, $aliasable)
@@ -252,20 +240,13 @@ class ReceiveEmail extends Command
             $alias->recipients()->sync($recipientIds);
         }
 
-        $emailData = new EmailData($this->parser);
+        $emailData = new EmailData($this->parser, $this->size);
 
         $alias->verifiedRecipientsOrDefault()->each(function ($recipient) use ($alias, $emailData) {
             $message = new ForwardEmail($alias, $emailData, $recipient);
 
             Mail::to($recipient->email)->queue($message);
         });
-
-        if (!Mail::failures()) {
-            $alias->increment('emails_forwarded');
-
-            $user->bandwidth += $this->size;
-            $user->save();
-        }
     }
 
     protected function checkBandwidthLimit($user)

+ 2 - 1
app/EmailData.php

@@ -6,7 +6,7 @@ use PhpMimeMailParser\Parser;
 
 class EmailData
 {
-    public function __construct(Parser $parser)
+    public function __construct(Parser $parser, $size)
     {
         $this->sender = $parser->getAddresses('from')[0]['address'];
         $this->display_from = base64_encode($parser->getAddresses('from')[0]['display']);
@@ -17,6 +17,7 @@ class EmailData
         $this->text = base64_encode($parser->getMessageBody('text'));
         $this->html = base64_encode($parser->getMessageBody('html'));
         $this->attachments = [];
+        $this->size = $size;
 
         if ($parser->getParts()[1]['content-type'] === 'multipart/encrypted') {
             $this->encryptedParts = $parser->getAttachments();

+ 20 - 4
app/Http/Controllers/Api/RuleController.php

@@ -22,10 +22,18 @@ class RuleController extends Controller
 
     public function store(StoreRuleRequest $request)
     {
+        $conditions = collect($request->conditions)->map(function ($condition) {
+            return collect($condition)->only(['type', 'match', 'values']);
+        });
+
+        $actions = collect($request->actions)->map(function ($action) {
+            return collect($action)->only(['type', 'value']);
+        });
+
         $rule = user()->rules()->create([
             'name' => $request->name,
-            'conditions' => $request->conditions,
-            'actions' => $request->actions,
+            'conditions' => $conditions,
+            'actions' => $actions,
             'operator' => $request->operator
         ]);
 
@@ -36,10 +44,18 @@ class RuleController extends Controller
     {
         $rule = user()->rules()->findOrFail($id);
 
+        $conditions = collect($request->conditions)->map(function ($condition) {
+            return collect($condition)->only(['type', 'match', 'values']);
+        });
+
+        $actions = collect($request->actions)->map(function ($action) {
+            return collect($action)->only(['type', 'value']);
+        });
+
         $rule->update([
             'name' => $request->name,
-            'conditions' => $request->conditions,
-            'actions' => $request->actions,
+            'conditions' => $conditions,
+            'actions' => $actions,
             'operator' => $request->operator
         ]);
 

+ 23 - 0
app/Listeners/CheckIfShouldBlock.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Listeners;
+
+use Illuminate\Mail\Events\MessageSending;
+
+class CheckIfShouldBlock
+{
+    /**
+     * Handle the event.
+     *
+     * @param  object  $event
+     * @return void
+     */
+    public function handle(MessageSending $event)
+    {
+        if (isset($event->data['shouldBlock'])) {
+            if ($event->data['shouldBlock']) {
+                return false;
+            }
+        }
+    }
+}

+ 20 - 7
app/Mail/ForwardEmail.php

@@ -39,6 +39,7 @@ class ForwardEmail extends Mailable implements ShouldQueue
     protected $dkimSigner;
     protected $encryptedParts;
     protected $fromEmail;
+    protected $size;
 
     /**
      * Create a new message instance.
@@ -57,6 +58,7 @@ class ForwardEmail extends Mailable implements ShouldQueue
         $this->emailHtml = $emailData->html;
         $this->emailAttachments = $emailData->attachments;
         $this->deactivateUrl = URL::signedRoute('deactivate', ['alias' => $alias->id]);
+        $this->size = $emailData->size;
 
         $this->encryptedParts = $emailData->encryptedParts ?? null;
 
@@ -112,13 +114,6 @@ class ForwardEmail extends Mailable implements ShouldQueue
             ->text('emails.forward.text')->with([
                 'text' => base64_decode($this->emailText)
             ])
-            ->with([
-                'location' => $this->bannerLocation,
-                'deactivateUrl' => $this->deactivateUrl,
-                'aliasEmail' => $this->alias->email,
-                'fromEmail' => $this->sender,
-                'replacedSubject' => $this->user->email_subject ? ' with subject "' . base64_decode($this->emailSubject) . '"' : null
-            ])
             ->withSwiftMessage(function ($message) use ($returnPath) {
                 $message->getHeaders()
                         ->addTextHeader('List-Unsubscribe', '<mailto:' . $this->alias->id . '@unsubscribe.' . config('anonaddy.domain') . '?subject=unsubscribe>, <' . $this->deactivateUrl . '>');
@@ -157,8 +152,26 @@ class ForwardEmail extends Mailable implements ShouldQueue
             );
         }
 
+        $this->replacedSubject = $this->user->email_subject ? ' with subject "' . base64_decode($this->emailSubject) . '"' : null;
+
         $this->checkRules();
 
+        $this->email->with([
+            'location' => $this->bannerLocation,
+            'deactivateUrl' => $this->deactivateUrl,
+            'aliasEmail' => $this->alias->email,
+            'fromEmail' => $this->sender,
+            'replacedSubject' => $this->replacedSubject,
+            'shouldBlock' => $this->size === 0
+        ]);
+
+        if ($this->size > 0) {
+            $this->alias->increment('emails_forwarded');
+
+            $this->user->bandwidth += $this->size;
+            $this->user->save();
+        }
+
         return $this->email;
     }
 

+ 36 - 15
app/Mail/ReplyToEmail.php

@@ -4,6 +4,8 @@ namespace App\Mail;
 
 use App\Alias;
 use App\EmailData;
+use App\Helpers\AlreadyEncryptedSigner;
+use App\Traits\CheckUserRules;
 use App\User;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
@@ -13,16 +15,21 @@ use Swift_Signers_DKIMSigner;
 
 class ReplyToEmail extends Mailable implements ShouldQueue
 {
-    use Queueable, SerializesModels;
+    use Queueable, SerializesModels, CheckUserRules;
 
+    protected $email;
     protected $user;
     protected $alias;
+    protected $sender;
     protected $emailSubject;
     protected $emailText;
     protected $emailHtml;
     protected $emailAttachments;
     protected $dkimSigner;
     protected $encryptedParts;
+    protected $displayFrom;
+    protected $fromEmail;
+    protected $size;
 
     /**
      * Create a new message instance.
@@ -33,11 +40,14 @@ class ReplyToEmail extends Mailable implements ShouldQueue
     {
         $this->user = $user;
         $this->alias = $alias;
+        $this->sender = $emailData->sender;
         $this->emailSubject = $emailData->subject;
         $this->emailText = $emailData->text;
         $this->emailHtml = $emailData->html;
         $this->emailAttachments = $emailData->attachments;
         $this->encryptedParts = $emailData->encryptedParts ?? null;
+        $this->displayFrom = $user->from_name ?? null;
+        $this->size = $emailData->size;
     }
 
     /**
@@ -47,26 +57,24 @@ class ReplyToEmail extends Mailable implements ShouldQueue
      */
     public function build()
     {
-        $fromName = $this->user->from_name ?? null;
-
         if ($this->alias->isCustomDomain()) {
             if ($this->alias->aliasable->isVerifiedForSending()) {
-                $fromEmail = $this->alias->email;
+                $this->fromEmail = $this->alias->email;
                 $returnPath = $this->alias->email;
 
                 $this->dkimSigner = new Swift_Signers_DKIMSigner(config('anonaddy.dkim_signing_key'), $this->alias->domain, config('anonaddy.dkim_selector'));
                 $this->dkimSigner->ignoreHeader('Return-Path');
             } else {
-                $fromEmail = config('mail.from.address');
+                $this->fromEmail = config('mail.from.address');
                 $returnPath = config('anonaddy.return_path');
             }
         } else {
-            $fromEmail = $this->alias->email;
+            $this->fromEmail = $this->alias->email;
             $returnPath = 'mailer@'.$this->alias->parentDomain();
         }
 
-        $email =  $this
-            ->from($fromEmail, $fromName)
+        $this->email =  $this
+            ->from($this->fromEmail, $this->displayFrom)
             ->subject(base64_decode($this->emailSubject))
             ->text('emails.reply.text')->with([
                 'text' => base64_decode($this->emailText)
@@ -88,24 +96,37 @@ class ReplyToEmail extends Mailable implements ShouldQueue
                 }
             });
 
-        if ($this->alias->isCustomDomain() && !$this->dkimSigner) {
-            $email->replyTo($this->alias->email, $fromName);
-        }
-
         if ($this->emailHtml) {
-            $email->view('emails.reply.html')->with([
+            $this->email->view('emails.reply.html')->with([
                 'html' => base64_decode($this->emailHtml)
             ]);
         }
 
         foreach ($this->emailAttachments as $attachment) {
-            $email->attachData(
+            $this->email->attachData(
                 base64_decode($attachment['stream']),
                 base64_decode($attachment['file_name']),
                 ['mime' => base64_decode($attachment['mime'])]
             );
         }
 
-        return $email;
+        $this->checkRules();
+
+        $this->email->with([
+            'shouldBlock' => $this->size === 0
+        ]);
+
+        if ($this->alias->isCustomDomain() && !$this->dkimSigner) {
+            $this->email->replyTo($this->alias->email, $this->displayFrom);
+        }
+
+        if ($this->size > 0) {
+            $this->alias->increment('emails_replied');
+
+            $this->user->bandwidth += $this->size;
+            $this->user->save();
+        }
+
+        return $this->email;
     }
 }

+ 35 - 15
app/Mail/SendFromEmail.php

@@ -5,6 +5,7 @@ namespace App\Mail;
 use App\Alias;
 use App\EmailData;
 use App\Helpers\AlreadyEncryptedSigner;
+use App\Traits\CheckUserRules;
 use App\User;
 use Illuminate\Bus\Queueable;
 use Illuminate\Contracts\Queue\ShouldQueue;
@@ -14,16 +15,21 @@ use Swift_Signers_DKIMSigner;
 
 class SendFromEmail extends Mailable implements ShouldQueue
 {
-    use Queueable, SerializesModels;
+    use Queueable, SerializesModels, CheckUserRules;
 
+    protected $email;
     protected $user;
     protected $alias;
+    protected $sender;
     protected $emailSubject;
     protected $emailText;
     protected $emailHtml;
     protected $emailAttachments;
     protected $dkimSigner;
     protected $encryptedParts;
+    protected $displayFrom;
+    protected $fromEmail;
+    protected $size;
 
     /**
      * Create a new message instance.
@@ -34,11 +40,14 @@ class SendFromEmail extends Mailable implements ShouldQueue
     {
         $this->user = $user;
         $this->alias = $alias;
+        $this->sender = $emailData->sender;
         $this->emailSubject = $emailData->subject;
         $this->emailText = $emailData->text;
         $this->emailHtml = $emailData->html;
         $this->emailAttachments = $emailData->attachments;
         $this->encryptedParts = $emailData->encryptedParts ?? null;
+        $this->displayFrom = $user->from_name ?? null;
+        $this->size = $emailData->size;
     }
 
     /**
@@ -48,26 +57,24 @@ class SendFromEmail extends Mailable implements ShouldQueue
      */
     public function build()
     {
-        $fromName = $this->user->from_name ?? null;
-
         if ($this->alias->isCustomDomain()) {
             if ($this->alias->aliasable->isVerifiedForSending()) {
-                $fromEmail = $this->alias->email;
+                $this->fromEmail = $this->alias->email;
                 $returnPath = $this->alias->email;
 
                 $this->dkimSigner = new Swift_Signers_DKIMSigner(config('anonaddy.dkim_signing_key'), $this->alias->domain, config('anonaddy.dkim_selector'));
                 $this->dkimSigner->ignoreHeader('Return-Path');
             } else {
-                $fromEmail = config('mail.from.address');
+                $this->fromEmail = config('mail.from.address');
                 $returnPath = config('anonaddy.return_path');
             }
         } else {
-            $fromEmail = $this->alias->email;
+            $this->fromEmail = $this->alias->email;
             $returnPath = 'mailer@'.$this->alias->parentDomain();
         }
 
-        $email =  $this
-            ->from($fromEmail, $fromName)
+        $this->email =  $this
+            ->from($this->fromEmail, $this->displayFrom)
             ->subject(base64_decode($this->emailSubject))
             ->text('emails.reply.text')->with([
                 'text' => base64_decode($this->emailText)
@@ -89,24 +96,37 @@ class SendFromEmail extends Mailable implements ShouldQueue
                 }
             });
 
-        if ($this->alias->isCustomDomain() && !$this->dkimSigner) {
-            $email->replyTo($this->alias->email, $fromName);
-        }
-
         if ($this->emailHtml) {
-            $email->view('emails.reply.html')->with([
+            $this->email->view('emails.reply.html')->with([
                 'html' => base64_decode($this->emailHtml)
             ]);
         }
 
         foreach ($this->emailAttachments as $attachment) {
-            $email->attachData(
+            $this->email->attachData(
                 base64_decode($attachment['stream']),
                 base64_decode($attachment['file_name']),
                 ['mime' => base64_decode($attachment['mime'])]
             );
         }
 
-        return $email;
+        $this->checkRules();
+
+        $this->email->with([
+            'shouldBlock' => $this->size === 0
+        ]);
+
+        if ($this->alias->isCustomDomain() && !$this->dkimSigner) {
+            $this->email->replyTo($this->alias->email, $this->displayFrom);
+        }
+
+        if ($this->size > 0) {
+            $this->alias->increment('emails_sent');
+
+            $this->user->bandwidth += $this->size;
+            $this->user->save();
+        }
+
+        return $this->email;
     }
 }

+ 5 - 0
app/Providers/EventServiceProvider.php

@@ -2,9 +2,11 @@
 
 namespace App\Providers;
 
+use App\Listeners\CheckIfShouldBlock;
 use Illuminate\Auth\Events\Registered;
 use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
 use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
+use Illuminate\Mail\Events\MessageSending;
 use Illuminate\Support\Facades\Event;
 
 class EventServiceProvider extends ServiceProvider
@@ -18,6 +20,9 @@ class EventServiceProvider extends ServiceProvider
         Registered::class => [
             SendEmailVerificationNotification::class,
         ],
+        MessageSending::class => [
+            CheckIfShouldBlock::class,
+        ]
     ];
 
     /**

+ 11 - 1
app/Traits/CheckUserRules.php

@@ -108,21 +108,31 @@ trait CheckUserRules
     {
         switch ($action['type']) {
             case 'subject':
+                $this->replacedSubject = ' with subject "' . base64_decode($this->emailSubject) . '"';
                 $this->email->subject = $action['value'];
                 break;
             case 'displayFrom':
+                $this->email->from = [];
                 $this->email->from($this->fromEmail, $action['value']);
                 break;
             case 'encryption':
                 if ($action['value'] == false) {
                     // detach the openpgpsigner from the email...
+                    if ($this->openpgpsigner) {
+                        $this->email->withSwiftMessage(function ($message) {
+                            $message->detachSigner($this->openpgpsigner);
+                        });
+                    }
                 }
                 break;
             case 'banner':
-                $this->email->location = $action['value'];
+                if (in_array($action['value'], ['top', 'bottom', 'off'])) {
+                    $this->email->bannerLocation = $action['value'];
+                }
                 break;
             case 'block':
                 $this->alias->increment('emails_blocked');
+                $this->size = 0;
                 exit(0);
                 break;
             case 'webhook':

+ 101 - 89
composer.lock

@@ -1448,16 +1448,16 @@
         },
         {
             "name": "laravel/framework",
-            "version": "v7.14.1",
+            "version": "v7.16.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/laravel/framework.git",
-                "reference": "469b7719a8dca40841a74f59f2e9f30f01d3a106"
+                "reference": "dc9cd8338d222dec2d9962553639e08c4585fa5b"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/laravel/framework/zipball/469b7719a8dca40841a74f59f2e9f30f01d3a106",
-                "reference": "469b7719a8dca40841a74f59f2e9f30f01d3a106",
+                "url": "https://api.github.com/repos/laravel/framework/zipball/dc9cd8338d222dec2d9962553639e08c4585fa5b",
+                "reference": "dc9cd8338d222dec2d9962553639e08c4585fa5b",
                 "shasum": ""
             },
             "require": {
@@ -1545,6 +1545,7 @@
             "suggest": {
                 "aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.0).",
                 "doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.6).",
+                "ext-ftp": "Required to use the Flysystem FTP driver.",
                 "ext-gd": "Required to use Illuminate\\Http\\Testing\\FileFactory::image().",
                 "ext-memcached": "Required to use the memcache cache driver.",
                 "ext-pcntl": "Required to use all features of the queue worker.",
@@ -1600,7 +1601,7 @@
                 "framework",
                 "laravel"
             ],
-            "time": "2020-06-02T22:34:18+00:00"
+            "time": "2020-06-16T14:31:25+00:00"
         },
         {
             "name": "laravel/passport",
@@ -2552,16 +2553,16 @@
         },
         {
             "name": "opis/closure",
-            "version": "3.5.3",
+            "version": "3.5.4",
             "source": {
                 "type": "git",
                 "url": "https://github.com/opis/closure.git",
-                "reference": "cac47092144043d5d676e2e7cf8d0d2f83fc89ca"
+                "reference": "1d0deef692f66dae5d70663caee2867d0971306b"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/opis/closure/zipball/cac47092144043d5d676e2e7cf8d0d2f83fc89ca",
-                "reference": "cac47092144043d5d676e2e7cf8d0d2f83fc89ca",
+                "url": "https://api.github.com/repos/opis/closure/zipball/1d0deef692f66dae5d70663caee2867d0971306b",
+                "reference": "1d0deef692f66dae5d70663caee2867d0971306b",
                 "shasum": ""
             },
             "require": {
@@ -2609,7 +2610,7 @@
                 "serialization",
                 "serialize"
             ],
-            "time": "2020-05-25T09:32:45+00:00"
+            "time": "2020-06-07T11:41:29+00:00"
         },
         {
             "name": "paragonie/constant_time_encoding",
@@ -2852,16 +2853,16 @@
         },
         {
             "name": "phpoption/phpoption",
-            "version": "1.7.3",
+            "version": "1.7.4",
             "source": {
                 "type": "git",
                 "url": "https://github.com/schmittjoh/php-option.git",
-                "reference": "4acfd6a4b33a509d8c88f50e5222f734b6aeebae"
+                "reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/4acfd6a4b33a509d8c88f50e5222f734b6aeebae",
-                "reference": "4acfd6a4b33a509d8c88f50e5222f734b6aeebae",
+                "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3",
+                "reference": "b2ada2ad5d8a32b89088b8adc31ecd2e3a13baf3",
                 "shasum": ""
             },
             "require": {
@@ -2903,7 +2904,17 @@
                 "php",
                 "type"
             ],
-            "time": "2020-03-21T18:07:53+00:00"
+            "funding": [
+                {
+                    "url": "https://github.com/GrahamCampbell",
+                    "type": "github"
+                },
+                {
+                    "url": "https://tidelift.com/funding/github/packagist/phpoption/phpoption",
+                    "type": "tidelift"
+                }
+            ],
+            "time": "2020-06-07T10:40:07+00:00"
         },
         {
             "name": "phpseclib/phpseclib",
@@ -3840,16 +3851,16 @@
         },
         {
             "name": "symfony/console",
-            "version": "v5.1.0",
+            "version": "v5.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/console.git",
-                "reference": "00bed125812716d09b163f0727ef33bb49bf3448"
+                "reference": "34ac555a3627e324b660e318daa07572e1140123"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/console/zipball/00bed125812716d09b163f0727ef33bb49bf3448",
-                "reference": "00bed125812716d09b163f0727ef33bb49bf3448",
+                "url": "https://api.github.com/repos/symfony/console/zipball/34ac555a3627e324b660e318daa07572e1140123",
+                "reference": "34ac555a3627e324b660e318daa07572e1140123",
                 "shasum": ""
             },
             "require": {
@@ -3929,11 +3940,11 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2020-05-30T20:35:19+00:00"
+            "time": "2020-06-15T12:59:21+00:00"
         },
         {
             "name": "symfony/css-selector",
-            "version": "v5.1.0",
+            "version": "v5.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/css-selector.git",
@@ -4060,7 +4071,7 @@
         },
         {
             "name": "symfony/error-handler",
-            "version": "v5.1.0",
+            "version": "v5.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/error-handler.git",
@@ -4131,7 +4142,7 @@
         },
         {
             "name": "symfony/event-dispatcher",
-            "version": "v5.1.0",
+            "version": "v5.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/event-dispatcher.git",
@@ -4289,7 +4300,7 @@
         },
         {
             "name": "symfony/finder",
-            "version": "v5.1.0",
+            "version": "v5.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/finder.git",
@@ -4352,16 +4363,16 @@
         },
         {
             "name": "symfony/http-foundation",
-            "version": "v5.1.0",
+            "version": "v5.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/http-foundation.git",
-                "reference": "e0d853bddc2b2cfb0d67b0b4496c03fffe1d37fa"
+                "reference": "f93055171b847915225bd5b0a5792888419d8d75"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/http-foundation/zipball/e0d853bddc2b2cfb0d67b0b4496c03fffe1d37fa",
-                "reference": "e0d853bddc2b2cfb0d67b0b4496c03fffe1d37fa",
+                "url": "https://api.github.com/repos/symfony/http-foundation/zipball/f93055171b847915225bd5b0a5792888419d8d75",
+                "reference": "f93055171b847915225bd5b0a5792888419d8d75",
                 "shasum": ""
             },
             "require": {
@@ -4423,20 +4434,20 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2020-05-24T12:18:07+00:00"
+            "time": "2020-06-15T06:52:54+00:00"
         },
         {
             "name": "symfony/http-kernel",
-            "version": "v5.1.0",
+            "version": "v5.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/http-kernel.git",
-                "reference": "75ff5327a7d6ede3ccc2fac3ebca9ed776b3e85c"
+                "reference": "a18c27ace1ef344ffcb129a5b089bad7643b387a"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/http-kernel/zipball/75ff5327a7d6ede3ccc2fac3ebca9ed776b3e85c",
-                "reference": "75ff5327a7d6ede3ccc2fac3ebca9ed776b3e85c",
+                "url": "https://api.github.com/repos/symfony/http-kernel/zipball/a18c27ace1ef344ffcb129a5b089bad7643b387a",
+                "reference": "a18c27ace1ef344ffcb129a5b089bad7643b387a",
                 "shasum": ""
             },
             "require": {
@@ -4536,20 +4547,20 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2020-05-31T06:14:18+00:00"
+            "time": "2020-06-15T13:51:38+00:00"
         },
         {
             "name": "symfony/mime",
-            "version": "v5.1.0",
+            "version": "v5.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/mime.git",
-                "reference": "56261f89385f9d13cf843a5101ac72131190bc91"
+                "reference": "c0c418f05e727606e85b482a8591519c4712cf45"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/mime/zipball/56261f89385f9d13cf843a5101ac72131190bc91",
-                "reference": "56261f89385f9d13cf843a5101ac72131190bc91",
+                "url": "https://api.github.com/repos/symfony/mime/zipball/c0c418f05e727606e85b482a8591519c4712cf45",
+                "reference": "c0c418f05e727606e85b482a8591519c4712cf45",
                 "shasum": ""
             },
             "require": {
@@ -4613,7 +4624,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2020-05-25T12:33:44+00:00"
+            "time": "2020-06-09T15:07:35+00:00"
         },
         {
             "name": "symfony/polyfill-ctype",
@@ -5279,7 +5290,7 @@
         },
         {
             "name": "symfony/process",
-            "version": "v5.1.0",
+            "version": "v5.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/process.git",
@@ -5407,16 +5418,16 @@
         },
         {
             "name": "symfony/routing",
-            "version": "v5.1.0",
+            "version": "v5.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/routing.git",
-                "reference": "95cf30145b26c758d6d832aa2d0de3128978d556"
+                "reference": "bbd0ba121d623f66d165a55a108008968911f3eb"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/routing/zipball/95cf30145b26c758d6d832aa2d0de3128978d556",
-                "reference": "95cf30145b26c758d6d832aa2d0de3128978d556",
+                "url": "https://api.github.com/repos/symfony/routing/zipball/bbd0ba121d623f66d165a55a108008968911f3eb",
+                "reference": "bbd0ba121d623f66d165a55a108008968911f3eb",
                 "shasum": ""
             },
             "require": {
@@ -5495,7 +5506,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2020-05-30T20:35:19+00:00"
+            "time": "2020-06-10T11:49:58+00:00"
         },
         {
             "name": "symfony/service-contracts",
@@ -5571,16 +5582,16 @@
         },
         {
             "name": "symfony/string",
-            "version": "v5.1.0",
+            "version": "v5.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/string.git",
-                "reference": "90c2a5103f07feb19069379f3abdcdbacc7753a9"
+                "reference": "ac70459db781108db7c6d8981dd31ce0e29e3298"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/string/zipball/90c2a5103f07feb19069379f3abdcdbacc7753a9",
-                "reference": "90c2a5103f07feb19069379f3abdcdbacc7753a9",
+                "url": "https://api.github.com/repos/symfony/string/zipball/ac70459db781108db7c6d8981dd31ce0e29e3298",
+                "reference": "ac70459db781108db7c6d8981dd31ce0e29e3298",
                 "shasum": ""
             },
             "require": {
@@ -5652,11 +5663,11 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2020-05-20T17:43:50+00:00"
+            "time": "2020-06-11T12:16:36+00:00"
         },
         {
             "name": "symfony/translation",
-            "version": "v5.1.0",
+            "version": "v5.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/translation.git",
@@ -5819,7 +5830,7 @@
         },
         {
             "name": "symfony/var-dumper",
-            "version": "v5.1.0",
+            "version": "v5.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/var-dumper.git",
@@ -5958,28 +5969,28 @@
         },
         {
             "name": "vlucas/phpdotenv",
-            "version": "v4.1.6",
+            "version": "v4.1.7",
             "source": {
                 "type": "git",
                 "url": "https://github.com/vlucas/phpdotenv.git",
-                "reference": "0b32505d67c1abbfa829283c86bfc0642a661bf6"
+                "reference": "db63b2ea280fdcf13c4ca392121b0b2450b51193"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/0b32505d67c1abbfa829283c86bfc0642a661bf6",
-                "reference": "0b32505d67c1abbfa829283c86bfc0642a661bf6",
+                "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/db63b2ea280fdcf13c4ca392121b0b2450b51193",
+                "reference": "db63b2ea280fdcf13c4ca392121b0b2450b51193",
                 "shasum": ""
             },
             "require": {
                 "php": "^5.5.9 || ^7.0 || ^8.0",
-                "phpoption/phpoption": "^1.7.2",
-                "symfony/polyfill-ctype": "^1.9"
+                "phpoption/phpoption": "^1.7.3",
+                "symfony/polyfill-ctype": "^1.16"
             },
             "require-dev": {
-                "bamarni/composer-bin-plugin": "^1.3",
+                "bamarni/composer-bin-plugin": "^1.4.1",
                 "ext-filter": "*",
                 "ext-pcre": "*",
-                "phpunit/phpunit": "^4.8.35 || ^5.0 || ^6.0 || ^7.0"
+                "phpunit/phpunit": "^4.8.35 || ^5.7.27 || ^6.5.6 || ^7.0"
             },
             "suggest": {
                 "ext-filter": "Required to use the boolean validator.",
@@ -6028,20 +6039,20 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2020-05-23T09:43:32+00:00"
+            "time": "2020-06-07T18:25:35+00:00"
         },
         {
             "name": "voku/portable-ascii",
-            "version": "1.5.1",
+            "version": "1.5.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/voku/portable-ascii.git",
-                "reference": "e7f9bd5deff09a57318f9b900ab33a05acfcf4d3"
+                "reference": "618631dc601d8eb6ea0a9fbf654ec82f066c4e97"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/voku/portable-ascii/zipball/e7f9bd5deff09a57318f9b900ab33a05acfcf4d3",
-                "reference": "e7f9bd5deff09a57318f9b900ab33a05acfcf4d3",
+                "url": "https://api.github.com/repos/voku/portable-ascii/zipball/618631dc601d8eb6ea0a9fbf654ec82f066c4e97",
+                "reference": "618631dc601d8eb6ea0a9fbf654ec82f066c4e97",
                 "shasum": ""
             },
             "require": {
@@ -6094,7 +6105,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2020-05-26T06:40:44+00:00"
+            "time": "2020-06-15T23:49:30+00:00"
         }
     ],
     "packages-dev": [
@@ -6473,16 +6484,16 @@
         },
         {
             "name": "facade/ignition",
-            "version": "2.0.6",
+            "version": "2.0.7",
             "source": {
                 "type": "git",
                 "url": "https://github.com/facade/ignition.git",
-                "reference": "5261c488a1e8a7c3ebdf6a4037c34f5ddeb33922"
+                "reference": "e6bedc1e74507d584fbcb041ebe0f7f215109cf2"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/facade/ignition/zipball/5261c488a1e8a7c3ebdf6a4037c34f5ddeb33922",
-                "reference": "5261c488a1e8a7c3ebdf6a4037c34f5ddeb33922",
+                "url": "https://api.github.com/repos/facade/ignition/zipball/e6bedc1e74507d584fbcb041ebe0f7f215109cf2",
+                "reference": "e6bedc1e74507d584fbcb041ebe0f7f215109cf2",
                 "shasum": ""
             },
             "require": {
@@ -6540,7 +6551,7 @@
                 "laravel",
                 "page"
             ],
-            "time": "2020-06-01T09:04:48+00:00"
+            "time": "2020-06-08T09:14:08+00:00"
         },
         {
             "name": "facade/ignition-contracts",
@@ -6588,16 +6599,16 @@
         },
         {
             "name": "filp/whoops",
-            "version": "2.7.2",
+            "version": "2.7.3",
             "source": {
                 "type": "git",
                 "url": "https://github.com/filp/whoops.git",
-                "reference": "17d0d3f266c8f925ebd035cd36f83cf802b47d4a"
+                "reference": "5d5fe9bb3d656b514d455645b3addc5f7ba7714d"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/filp/whoops/zipball/17d0d3f266c8f925ebd035cd36f83cf802b47d4a",
-                "reference": "17d0d3f266c8f925ebd035cd36f83cf802b47d4a",
+                "url": "https://api.github.com/repos/filp/whoops/zipball/5d5fe9bb3d656b514d455645b3addc5f7ba7714d",
+                "reference": "5d5fe9bb3d656b514d455645b3addc5f7ba7714d",
                 "shasum": ""
             },
             "require": {
@@ -6645,7 +6656,7 @@
                 "throwable",
                 "whoops"
             ],
-            "time": "2020-05-05T12:28:07+00:00"
+            "time": "2020-06-14T09:00:00+00:00"
         },
         {
             "name": "friendsofphp/php-cs-fixer",
@@ -7660,16 +7671,16 @@
         },
         {
             "name": "phpunit/phpunit",
-            "version": "8.5.5",
+            "version": "8.5.6",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/phpunit.git",
-                "reference": "63dda3b212a0025d380a745f91bdb4d8c985adb7"
+                "reference": "3f9c4079d1407cd84c51c02c6ad1df6ec2ed1348"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/63dda3b212a0025d380a745f91bdb4d8c985adb7",
-                "reference": "63dda3b212a0025d380a745f91bdb4d8c985adb7",
+                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3f9c4079d1407cd84c51c02c6ad1df6ec2ed1348",
+                "reference": "3f9c4079d1407cd84c51c02c6ad1df6ec2ed1348",
                 "shasum": ""
             },
             "require": {
@@ -7749,7 +7760,7 @@
                     "type": "github"
                 }
             ],
-            "time": "2020-05-22T13:51:52+00:00"
+            "time": "2020-06-15T10:45:47+00:00"
         },
         {
             "name": "scrivo/highlight.php",
@@ -8437,7 +8448,7 @@
         },
         {
             "name": "symfony/filesystem",
-            "version": "v5.1.0",
+            "version": "v5.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/filesystem.git",
@@ -8501,7 +8512,7 @@
         },
         {
             "name": "symfony/options-resolver",
-            "version": "v5.1.0",
+            "version": "v5.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/options-resolver.git",
@@ -8644,7 +8655,7 @@
         },
         {
             "name": "symfony/stopwatch",
-            "version": "v5.1.0",
+            "version": "v5.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/stopwatch.git",
@@ -8748,16 +8759,16 @@
         },
         {
             "name": "webmozart/assert",
-            "version": "1.8.0",
+            "version": "1.9.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/webmozart/assert.git",
-                "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6"
+                "reference": "9dc4f203e36f2b486149058bade43c851dd97451"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/webmozart/assert/zipball/ab2cb0b3b559010b75981b1bdce728da3ee90ad6",
-                "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6",
+                "url": "https://api.github.com/repos/webmozart/assert/zipball/9dc4f203e36f2b486149058bade43c851dd97451",
+                "reference": "9dc4f203e36f2b486149058bade43c851dd97451",
                 "shasum": ""
             },
             "require": {
@@ -8765,6 +8776,7 @@
                 "symfony/polyfill-ctype": "^1.8"
             },
             "conflict": {
+                "phpstan/phpstan": "<0.12.20",
                 "vimeo/psalm": "<3.9.1"
             },
             "require-dev": {
@@ -8792,7 +8804,7 @@
                 "check",
                 "validate"
             ],
-            "time": "2020-04-18T12:12:48+00:00"
+            "time": "2020-06-16T10:16:42+00:00"
         }
     ],
     "aliases": [],

+ 112 - 6
resources/js/pages/Rules.vue

@@ -288,6 +288,7 @@
                     <div class="relative">
                       <select
                         v-model="createRuleObject.actions[key].type"
+                        @change="ruleActionChange(createRuleObject.actions[key])"
                         id="rule_action_types"
                         class="block appearance-none text-grey-700 bg-white p-2 pr-6 rounded shadow focus:shadow-outline"
                         required
@@ -315,7 +316,13 @@
                     </div>
                   </span>
 
-                  <span v-if="createRuleObject.actions[key].type === 'subject'" class="ml-4 flex">
+                  <span
+                    v-if="
+                      createRuleObject.actions[key].type === 'subject' ||
+                        createRuleObject.actions[key].type === 'displayFrom'
+                    "
+                    class="ml-4 flex"
+                  >
                     <div class="flex">
                       <input
                         v-model="createRuleObject.actions[key].value"
@@ -327,6 +334,37 @@
                       />
                     </div>
                   </span>
+
+                  <span
+                    v-else-if="createRuleObject.actions[key].type === 'banner'"
+                    class="ml-4 flex"
+                  >
+                    <div class="relative mr-4">
+                      <select
+                        v-model="createRuleObject.actions[key].value"
+                        id="create_rule_action_banner"
+                        class="block appearance-none w-40 text-grey-700 bg-white p-2 pr-6 rounded shadow focus:shadow-outline"
+                        required
+                      >
+                        <option selected value="top">Top </option>
+                        <option selected value="bottom">Bottom </option>
+                        <option selected value="off">Off </option>
+                      </select>
+                      <div
+                        class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700"
+                      >
+                        <svg
+                          class="fill-current h-4 w-4"
+                          xmlns="http://www.w3.org/2000/svg"
+                          viewBox="0 0 20 20"
+                        >
+                          <path
+                            d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"
+                          />
+                        </svg>
+                      </div>
+                    </div>
+                  </span>
                 </div>
                 <div class="flex items-center">
                   <!-- delete button -->
@@ -582,6 +620,7 @@
                     <div class="relative">
                       <select
                         v-model="editRuleObject.actions[key].type"
+                        @change="ruleActionChange(editRuleObject.actions[key])"
                         id="rule_action_types"
                         class="block appearance-none text-grey-700 bg-white p-2 pr-6 rounded shadow focus:shadow-outline"
                         required
@@ -609,7 +648,13 @@
                     </div>
                   </span>
 
-                  <span v-if="editRuleObject.actions[key].type === 'subject'" class="ml-4 flex">
+                  <span
+                    v-if="
+                      editRuleObject.actions[key].type === 'subject' ||
+                        editRuleObject.actions[key].type === 'displayFrom'
+                    "
+                    class="ml-4 flex"
+                  >
                     <div class="flex">
                       <input
                         v-model="editRuleObject.actions[key].value"
@@ -621,6 +666,34 @@
                       />
                     </div>
                   </span>
+
+                  <span v-else-if="editRuleObject.actions[key].type === 'banner'" class="ml-4 flex">
+                    <div class="relative mr-4">
+                      <select
+                        v-model="editRuleObject.actions[key].value"
+                        id="edit_rule_action_banner"
+                        class="block appearance-none w-40 text-grey-700 bg-white p-2 pr-6 rounded shadow focus:shadow-outline"
+                        required
+                      >
+                        <option value="top">Top </option>
+                        <option value="bottom">Bottom </option>
+                        <option value="off">Off </option>
+                      </select>
+                      <div
+                        class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700"
+                      >
+                        <svg
+                          class="fill-current h-4 w-4"
+                          xmlns="http://www.w3.org/2000/svg"
+                          viewBox="0 0 20 20"
+                        >
+                          <path
+                            d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"
+                          />
+                        </svg>
+                      </div>
+                    </div>
+                  </span>
                 </div>
                 <div class="flex items-center">
                   <!-- delete button -->
@@ -776,6 +849,22 @@ export default {
           value: 'subject',
           label: 'replace the subject with',
         },
+        {
+          value: 'displayFrom',
+          label: 'replace the "from name" with',
+        },
+        {
+          value: 'encryption',
+          label: 'turn PGP encryption off',
+        },
+        {
+          value: 'banner',
+          label: 'set the banner information location to',
+        },
+        {
+          value: 'block',
+          label: 'block the email',
+        },
       ],
       errors: {},
     }
@@ -863,7 +952,10 @@ export default {
         return (this.errors.ruleConditions = 'You must add some values for the condition')
       }
 
-      if (!this.createRuleObject.actions[0].value) {
+      if (
+        !this.createRuleObject.actions[0].value &&
+        this.createRuleObject.actions[0].value !== false
+      ) {
         return (this.errors.ruleActions = 'You must add a value for the action')
       }
 
@@ -909,7 +1001,7 @@ export default {
         return (this.errors.ruleConditions = 'You must add some values for the condition')
       }
 
-      if (!this.editRuleObject.actions[0].value) {
+      if (!this.editRuleObject.actions[0].value && this.editRuleObject.actions[0].value !== false) {
         return (this.errors.ruleActions = 'You must add a value for the action')
       }
 
@@ -942,8 +1034,11 @@ export default {
         })
         .catch(error => {
           this.editRuleLoading = false
-          this.editRuleObject = {}
-          this.error()
+          if (error.response.data) {
+            this.error(Object.entries(error.response.data.errors)[0][1][0])
+          } else {
+            this.error()
+          }
         })
     },
     activateRule(id) {
@@ -1066,6 +1161,17 @@ export default {
         operator: 'AND',
       }
     },
+    ruleActionChange(action) {
+      if (action.type === 'subject' || action.type === 'displayFrom' || action.type === 'select') {
+        action.value = ''
+      } else if (action.type === 'encryption') {
+        action.value = false
+      } else if (action.type === 'banner') {
+        action.value = 'top'
+      } else if (action.type === 'block') {
+        action.value = true
+      }
+    },
     success(text = '') {
       this.$notify({
         title: 'Success',

+ 6 - 2
tests/Feature/Api/RulesTest.php

@@ -246,7 +246,9 @@ class RulesTest extends TestCase
 
         $parser = $this->getParser(base_path('tests/emails/email.eml'));
 
-        $emailData = new EmailData($parser);
+        $size = 1500;
+
+        $emailData = new EmailData($parser, $size);
 
         $job = new ForwardEmail($alias, $emailData, $this->user->defaultRecipient);
 
@@ -322,7 +324,9 @@ class RulesTest extends TestCase
 
         $parser = $this->getParser(base_path('tests/emails/email.eml'));
 
-        $emailData = new EmailData($parser);
+        $size = 1000;
+
+        $emailData = new EmailData($parser, $size);
 
         $job = new ForwardEmail($alias, $emailData, $this->user->defaultRecipient);
 

+ 11 - 140
tests/Feature/ReceiveEmailTest.php

@@ -55,15 +55,9 @@ class ReceiveEmailTest extends TestCase
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'ebay',
             'domain' => 'johndoe.'.config('anonaddy.domain'),
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
         $this->assertEquals(1, $this->user->aliases()->count());
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '1000'
-        ]);
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) {
             return $mail->hasTo($this->user->email);
@@ -96,15 +90,9 @@ class ReceiveEmailTest extends TestCase
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'ebay',
             'domain' => 'johndoe.'.config('anonaddy.domain'),
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
         $this->assertEquals(1, $this->user->aliases()->count());
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '1000'
-        ]);
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) {
             return $mail->hasTo($this->user->email);
@@ -135,15 +123,9 @@ class ReceiveEmailTest extends TestCase
             'email' => 'attachment@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'attachment',
             'domain' => 'johndoe.'.config('anonaddy.domain'),
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
         $this->assertEquals(1, $this->user->aliases()->count());
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '1000'
-        ]);
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) {
             return $mail->hasTo($this->user->email);
@@ -174,29 +156,21 @@ class ReceiveEmailTest extends TestCase
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'ebay',
             'domain' => 'johndoe.'.config('anonaddy.domain'),
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
         $this->assertDatabaseHas('aliases', [
             'email' => 'amazon@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'amazon',
             'domain' => 'johndoe.'.config('anonaddy.domain'),
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
         $this->assertDatabaseHas('aliases', [
             'email' => 'paypal@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'paypal',
             'domain' => 'johndoe.'.config('anonaddy.domain'),
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
         $this->assertEquals(3, $this->user->aliases()->count());
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '1217'
-        ]);
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) {
             return $mail->hasTo($this->user->email);
@@ -227,14 +201,9 @@ class ReceiveEmailTest extends TestCase
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'ebay',
             'domain' => 'johndoe.'.config('anonaddy.domain'),
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '789'
-        ]);
+
         $this->assertEquals(1, $this->user->aliases()->count());
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) {
@@ -273,14 +242,9 @@ class ReceiveEmailTest extends TestCase
 
         $this->assertDatabaseHas('aliases', [
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '559'
-        ]);
+
         $this->assertCount(1, $this->user->aliases);
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) use ($defaultRecipient) {
@@ -328,14 +292,9 @@ class ReceiveEmailTest extends TestCase
             'local_part' => $uuid,
             'domain' => 'anonaddy.me',
             'email' => $uuid.'@anonaddy.me',
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '892'
-        ]);
+
         $this->assertCount(1, $this->user->aliases);
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) use ($defaultRecipient) {
@@ -382,14 +341,9 @@ class ReceiveEmailTest extends TestCase
             'local_part' => $localPart,
             'domain' => 'anonaddy.me',
             'email' => $localPart.'@anonaddy.me',
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '892'
-        ]);
+
         $this->assertCount(1, $this->user->aliases);
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) use ($defaultRecipient) {
@@ -446,14 +400,8 @@ class ReceiveEmailTest extends TestCase
 
         $this->assertDatabaseHas('aliases', [
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '444'
-        ]);
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) {
             return $mail->hasTo('one@example.com');
@@ -497,14 +445,8 @@ class ReceiveEmailTest extends TestCase
         $this->assertDatabaseHas('aliases', [
             'extension' => '2.3',
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '444'
-        ]);
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) use ($recipient) {
             return $mail->hasTo($recipient->email);
@@ -522,8 +464,6 @@ class ReceiveEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        $defaultRecipient = $this->user->defaultRecipient;
-
         factory(Recipient::class)->create([
             'user_id' => $this->user->id,
             'email' => 'one@example.com',
@@ -550,20 +490,14 @@ class ReceiveEmailTest extends TestCase
 
         $this->assertDatabaseHas('aliases', [
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '444'
-        ]);
 
         $alias = $this->user->aliases()->where('email', 'ebay@johndoe.'.config('anonaddy.domain'))->first();
 
         $this->assertCount(1, $alias->recipients);
 
-        Mail::assertQueued(ForwardEmail::class, function ($mail) use ($defaultRecipient, $verifiedRecipient) {
+        Mail::assertQueued(ForwardEmail::class, function ($mail) use ($verifiedRecipient) {
             return $mail->hasTo($verifiedRecipient->email);
         });
     }
@@ -597,12 +531,6 @@ class ReceiveEmailTest extends TestCase
             'emails_blocked' => 0
         ]);
 
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '0'
-        ]);
-
         Mail::assertNotSent(ForwardEmail::class);
     }
 
@@ -654,11 +582,6 @@ class ReceiveEmailTest extends TestCase
             'domain' => 'johndoe.'.config('anonaddy.domain'),
             'active' => false
         ]);
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '0'
-        ]);
 
         Mail::assertNotSent(ForwardEmail::class);
     }
@@ -718,11 +641,6 @@ class ReceiveEmailTest extends TestCase
             'domain' => 'johndoe.'.config('anonaddy.domain'),
             'active' => true
         ]);
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '1000'
-        ]);
 
         Mail::assertNotSent(ForwardEmail::class);
     }
@@ -770,11 +688,6 @@ class ReceiveEmailTest extends TestCase
             'domain' => 'johndoe.'.config('anonaddy.domain'),
             'active' => true
         ]);
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '0'
-        ]);
 
         Mail::assertNotSent(ForwardEmail::class);
     }
@@ -805,14 +718,9 @@ class ReceiveEmailTest extends TestCase
             'email' => 'ebay@anonaddy.me',
             'local_part' => 'ebay',
             'domain' => 'anonaddy.me',
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '1346'
-        ]);
+
         $this->assertEquals(1, $this->user->aliases()->count());
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) {
@@ -852,14 +760,9 @@ class ReceiveEmailTest extends TestCase
             'email' => 'ebay@example.com',
             'local_part' => 'ebay',
             'domain' => 'example.com',
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '871'
-        ]);
+
         $this->assertEquals(1, $this->user->aliases()->count());
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) {
@@ -900,14 +803,9 @@ class ReceiveEmailTest extends TestCase
             'email' => 'ebay@example.com',
             'local_part' => 'ebay',
             'domain' => 'example.com',
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '871'
-        ]);
+
         $this->assertEquals(1, $this->user->aliases()->count());
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) {
@@ -946,14 +844,9 @@ class ReceiveEmailTest extends TestCase
             'email' => 'ebay@janedoe.anonaddy.com',
             'local_part' => 'ebay',
             'domain' => 'janedoe.anonaddy.com',
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '638'
-        ]);
+
         $this->assertEquals(1, $this->user->aliases()->count());
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) {
@@ -987,15 +880,9 @@ class ReceiveEmailTest extends TestCase
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'ebay',
             'domain' => 'johndoe.'.config('anonaddy.domain'),
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
         $this->assertEquals(1, $this->user->aliases()->count());
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '100944820'
-        ]);
 
         Notification::assertSentTo(
             $this->user,
@@ -1071,15 +958,9 @@ class ReceiveEmailTest extends TestCase
             'email' => 'ebay@johndoe.anonaddy.me',
             'local_part' => 'ebay',
             'domain' => 'johndoe.anonaddy.me',
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
         $this->assertEquals(1, $this->user->aliases()->count());
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '1000'
-        ]);
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) {
             return $mail->hasTo($this->user->email);
@@ -1123,14 +1004,9 @@ class ReceiveEmailTest extends TestCase
             'email' => 'ebay@example.com',
             'local_part' => 'ebay',
             'domain' => 'example.com',
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '871'
-        ]);
+
         $this->assertEquals(1, $this->user->aliases()->count());
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) use ($recipient) {
@@ -1174,14 +1050,9 @@ class ReceiveEmailTest extends TestCase
             'email' => 'ebay@janedoe.anonaddy.com',
             'local_part' => 'ebay',
             'domain' => 'janedoe.anonaddy.com',
-            'emails_forwarded' => 1,
             'emails_blocked' => 0
         ]);
-        $this->assertDatabaseHas('users', [
-            'id' => $this->user->id,
-            'username' => 'johndoe',
-            'bandwidth' => '559'
-        ]);
+
         $this->assertEquals(1, $this->user->aliases()->count());
 
         Mail::assertQueued(ForwardEmail::class, function ($mail) use ($recipient) {

+ 0 - 24
tests/Feature/ReplyToEmailTest.php

@@ -53,14 +53,6 @@ class ReplyToEmailTest extends TestCase
             ]
         )->assertExitCode(0);
 
-        $this->assertDatabaseHas('aliases', [
-            'email' => $alias->email,
-            'local_part' => $alias->local_part,
-            'domain' => $alias->domain,
-            'emails_forwarded' => 0,
-            'emails_blocked' => 0,
-            'emails_replied' => 1
-        ]);
         $this->assertEquals(1, $this->user->aliases()->count());
 
         Mail::assertQueued(ReplyToEmail::class, function ($mail) {
@@ -102,14 +94,6 @@ class ReplyToEmailTest extends TestCase
             ]
         )->assertExitCode(0);
 
-        $this->assertDatabaseHas('aliases', [
-            'email' => $alias->email,
-            'local_part' => $alias->local_part,
-            'domain' => $alias->domain,
-            'emails_forwarded' => 1,
-            'emails_blocked' => 0,
-            'emails_replied' => 0
-        ]);
         $this->assertEquals(1, $this->user->aliases()->count());
 
         Mail::assertNotQueued(ReplyToEmail::class, function ($mail) {
@@ -150,14 +134,6 @@ class ReplyToEmailTest extends TestCase
             ]
         )->assertExitCode(0);
 
-        $this->assertDatabaseHas('aliases', [
-            'email' => $alias->email,
-            'local_part' => $alias->local_part,
-            'domain' => $alias->domain,
-            'emails_forwarded' => 0,
-            'emails_blocked' => 0,
-            'emails_replied' => 2
-        ]);
         $this->assertEquals(1, $this->user->aliases()->count());
 
         Mail::assertQueued(ReplyToEmail::class, function ($mail) {

+ 1 - 20
tests/Feature/SendFromEmailTest.php

@@ -52,15 +52,6 @@ class SendFromEmailTest extends TestCase
             ]
         )->assertExitCode(0);
 
-        $this->assertDatabaseHas('aliases', [
-            'email' => $alias->email,
-            'local_part' => $alias->local_part,
-            'domain' => $alias->domain,
-            'emails_forwarded' => 0,
-            'emails_blocked' => 0,
-            'emails_replied' => 0,
-            'emails_sent' => 1
-        ]);
         $this->assertEquals(1, $this->user->aliases()->count());
 
         Mail::assertQueued(SendFromEmail::class, function ($mail) {
@@ -75,7 +66,7 @@ class SendFromEmailTest extends TestCase
 
         Mail::assertNothingSent();
 
-        $alias = factory(Alias::class)->create([
+        factory(Alias::class)->create([
             'user_id' => $this->user->id,
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
             'local_part' => 'ebay',
@@ -101,15 +92,6 @@ class SendFromEmailTest extends TestCase
             ]
         )->assertExitCode(0);
 
-        $this->assertDatabaseHas('aliases', [
-            'email' => $alias->email,
-            'local_part' => $alias->local_part,
-            'domain' => $alias->domain,
-            'emails_forwarded' => 0,
-            'emails_blocked' => 0,
-            'emails_replied' => 0,
-            'emails_sent' => 2
-        ]);
         $this->assertEquals(1, $this->user->aliases()->count());
 
         Mail::assertQueued(SendFromEmail::class, function ($mail) {
@@ -154,7 +136,6 @@ class SendFromEmailTest extends TestCase
             'emails_forwarded' => 0,
             'emails_blocked' => 0,
             'emails_replied' => 0,
-            'emails_sent' => 1
         ]);
         $this->assertEquals(1, $this->user->aliases()->count());