瀏覽代碼

Added extension column to aliases

Will Browning 6 年之前
父節點
當前提交
c7979935c3

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

@@ -179,9 +179,11 @@ class ReceiveEmail extends Command
             }
 
             if ($recipient['extension'] !== '') {
+                $alias->extension = $recipient['extension'];
+
                 $keys = explode('.', $recipient['extension']);
 
-                $recipient_ids = $user
+                $recipientIds = $user
                                     ->recipients()
                                     ->oldest()
                                     ->get()
@@ -197,8 +199,8 @@ class ReceiveEmail extends Command
         $alias->save();
         $alias->refresh();
 
-        if (isset($recipient_ids)) {
-            $alias->recipients()->sync($recipient_ids);
+        if (isset($recipientIds)) {
+            $alias->recipients()->sync($recipientIds);
         }
 
         $emailData = new EmailData($this->parser);

+ 32 - 0
database/migrations/2019_08_01_090418_add_extension_column_to_aliases_table.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddExtensionColumnToAliasesTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('aliases', function (Blueprint $table) {
+            $table->string('extension')->after('local_part')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('aliases', function (Blueprint $table) {
+            $table->dropColumn('extension');
+        });
+    }
+}

+ 3 - 3
package-lock.json

@@ -8427,9 +8427,9 @@
             "dev": true
         },
         "tailwindcss": {
-            "version": "1.0.5",
-            "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-1.0.5.tgz",
-            "integrity": "sha512-e5edrSKqNOvWAVEutXN5czeJSXjQQxO7zNN4RDd5vQF/JTxnKdndcMFIC6p6YkRvcGFKPCZ/0rY1zZvPeq9V4A==",
+            "version": "1.0.6",
+            "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-1.0.6.tgz",
+            "integrity": "sha512-hhdvXpnlYNnxfZCpldMypSWRzgmoQbKBy3namGlsP0Gs+qM8EwF3DBVUPoq8wJYbBFjzrgatE4czWJ6f12Y9+Q==",
             "requires": {
                 "autoprefixer": "^9.4.5",
                 "bytes": "^3.0.0",

+ 1 - 1
package.json

@@ -21,7 +21,7 @@
         "postcss-import": "^11.1.0",
         "postcss-nesting": "^5.0.0",
         "resolve-url-loader": "^2.3.2",
-        "tailwindcss": "^1.0.5",
+        "tailwindcss": "^1.0.6",
         "tippy.js": "^4.3.4",
         "v-clipboard": "^2.2.2",
         "vue": "^2.6.10",

+ 9 - 2
resources/js/pages/Aliases.vue

@@ -294,14 +294,16 @@
               <span
                 class="tooltip cursor-pointer outline-none"
                 data-tippy-content="Click to copy"
-                v-clipboard="() => alias.email"
+                v-clipboard="() => getAliasEmail(alias)"
                 v-clipboard:success="clipboardSuccess"
                 v-clipboard:error="clipboardError"
               >
                 <span class="font-semibold text-indigo-800">{{
                   alias.local_part | truncate(20)
                 }}</span>
-                <span class="block text-grey-400 text-sm">{{ alias.email | truncate(35) }}</span>
+                <span class="block text-grey-400 text-sm">{{
+                  getAliasEmail(alias) | truncate(35)
+                }}</span>
               </span>
             </div>
           </td>
@@ -784,6 +786,11 @@ export default {
           this.error()
         })
     },
+    getAliasEmail(alias) {
+      return alias.extension
+        ? `${alias.local_part}+${alias.extension}@${alias.domain}`
+        : alias.email
+    },
     clipboardSuccess() {
       this.success('Copied to clipboard')
     },

+ 1 - 0
tests/Feature/ReceiveEmailTest.php

@@ -342,6 +342,7 @@ class ReceiveEmailTest extends TestCase
         )->assertExitCode(0);
 
         $this->assertDatabaseHas('aliases', [
+            'extension' => '2.3',
             'email' => 'ebay@johndoe.'.config('anonaddy.domain'),
             'emails_forwarded' => 1,
             'emails_blocked' => 0