Browse Source

Added info on attaching recipients

Will Browning 6 years ago
parent
commit
d1802e0e1e

+ 7 - 8
app/Console/Commands/ReceiveEmail.php

@@ -147,8 +147,7 @@ class ReceiveEmail extends Command
             Mail::to($displayTo)->queue($message);
             Mail::to($displayTo)->queue($message);
 
 
             if (!Mail::failures()) {
             if (!Mail::failures()) {
-                $alias->emails_replied += 1;
-                $alias->save();
+                $alias->increment('emails_replied');
 
 
                 $user->bandwidth += $this->size;
                 $user->bandwidth += $this->size;
                 $user->save();
                 $user->save();
@@ -178,15 +177,16 @@ class ReceiveEmail extends Command
             }
             }
 
 
             if ($recipient['extension'] !== '') {
             if ($recipient['extension'] !== '') {
-                $ids = explode('.', $recipient['extension']);
+                $keys = explode('.', $recipient['extension']);
 
 
                 $recipient_ids = $user
                 $recipient_ids = $user
                                     ->recipients()
                                     ->recipients()
-                                    ->latest()
+                                    ->oldest()
                                     ->pluck('id')
                                     ->pluck('id')
-                                    ->filter(function ($value, $key) use ($ids) {
-                                        return in_array($key+1, $ids);
+                                    ->filter(function ($value, $key) use ($keys) {
+                                        return in_array($key+1, $keys);
                                     })
                                     })
+                                    ->take(10)
                                     ->toArray();
                                     ->toArray();
             }
             }
         }
         }
@@ -213,8 +213,7 @@ class ReceiveEmail extends Command
         }
         }
 
 
         if (!Mail::failures()) {
         if (!Mail::failures()) {
-            $alias->emails_forwarded += 1;
-            $alias->save();
+            $alias->increment('emails_forwarded');
 
 
             $user->bandwidth += $this->size;
             $user->bandwidth += $this->size;
             $user->save();
             $user->save();

+ 6 - 0
app/Http/Controllers/RecipientController.php

@@ -11,6 +11,12 @@ class RecipientController extends Controller
     {
     {
         $recipients = user()->recipients()->with('aliases')->latest()->get();
         $recipients = user()->recipients()->with('aliases')->latest()->get();
 
 
+        $count = $recipients->count();
+
+        $recipients->each(function ($item, $key) use ($count) {
+            $item['key'] = $count - $key;
+        });
+
         return view('recipients.index', [
         return view('recipients.index', [
             'recipients' => $recipients,
             'recipients' => $recipients,
             'aliasesUsingDefault' => user()->aliasesUsingDefault
             'aliasesUsingDefault' => user()->aliasesUsingDefault

+ 6 - 0
resources/js/components/Icon.vue

@@ -74,6 +74,12 @@
     ></path>
     ></path>
   </svg>
   </svg>
 
 
+  <svg v-else-if="name === 'info'" xmlns="http://www.w3.org/2000/svg" viewBox="-2 -2 24 24">
+    <path
+      d="M10 20C4.477 20 0 15.523 0 10S4.477 0 10 0s10 4.477 10 10-4.477 10-10 10zm0-2a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm0-10a1 1 0 0 1 1 1v5a1 1 0 0 1-2 0V9a1 1 0 0 1 1-1zm0-1a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"
+    ></path>
+  </svg>
+
   <svg v-else-if="name === 'close'" xmlns="http://www.w3.org/2000/svg" viewBox="-6 -6 24 24">
   <svg v-else-if="name === 'close'" xmlns="http://www.w3.org/2000/svg" viewBox="-6 -6 24 24">
     <path
     <path
       d="M7.314 5.9l3.535-3.536A1 1 0 1 0 9.435.95L5.899 4.485 2.364.95A1 1 0 1 0 .95 2.364l3.535 3.535L.95 9.435a1 1 0 1 0 1.414 1.414l3.535-3.535 3.536 3.535a1 1 0 1 0 1.414-1.414L7.314 5.899z"
       d="M7.314 5.9l3.535-3.536A1 1 0 1 0 9.435.95L5.899 4.485 2.364.95A1 1 0 1 0 .95 2.364l3.535 3.535L.95 9.435a1 1 0 1 0 1.414 1.414l3.535-3.535 3.536 3.535a1 1 0 1 0 1.414-1.414L7.314 5.899z"

+ 40 - 1
resources/js/pages/Recipients.vue

@@ -55,6 +55,39 @@
               </div>
               </div>
             </div>
             </div>
           </th>
           </th>
+          <th class="p-4">
+            <div class="flex items-center">
+              Key
+              <div class="inline-flex flex-col">
+                <icon
+                  name="chevron-up"
+                  @click.native="sort('key', 'asc')"
+                  class="w-4 h-4 text-grey-300 fill-current cursor-pointer"
+                  :class="{ 'text-grey-800': isCurrentSort('key', 'asc') }"
+                />
+                <icon
+                  name="chevron-down"
+                  @click.native="sort('key', 'desc')"
+                  class="w-4 h-4 text-grey-300 fill-current cursor-pointer"
+                  :class="{
+                    'text-grey-800': isCurrentSort('key', 'desc'),
+                  }"
+                />
+              </div>
+              <span
+                class="tooltip outline-none"
+                :data-tippy-content="
+                  `Use this to attach recipients to new aliases as they are created e.g. alias+key@${
+                    user.username
+                  }.anonaddy.com. You can attach multiple recipients by doing alias+2.3@${
+                    user.username
+                  }.anonaddy.com`
+                "
+              >
+                <icon name="info" class="inline-block w-4 h-4 text-grey-200 fill-current" />
+              </span>
+            </div>
+          </th>
           <th class="p-4">
           <th class="p-4">
             <div class="flex items-center">
             <div class="flex items-center">
               Email
               Email
@@ -140,6 +173,11 @@
               >
               >
             </div>
             </div>
           </td>
           </td>
+          <td class="border-grey-200 border-t">
+            <div class="p-4 flex items-center">
+              {{ recipient.key }}
+            </div>
+          </td>
           <td class="border-grey-200 border-t">
           <td class="border-grey-200 border-t">
             <div class="p-4 flex items-center focus:text-indigo-500">
             <div class="p-4 flex items-center focus:text-indigo-500">
               <span
               <span
@@ -235,7 +273,7 @@
         <tr v-if="queriedRecipients.length === 0">
         <tr v-if="queriedRecipients.length === 0">
           <td
           <td
             class="border-grey-200 border-t p-4 text-center h-24 text-lg text-grey-700"
             class="border-grey-200 border-t p-4 text-center h-24 text-lg text-grey-700"
-            colspan="5"
+            colspan="6"
           >
           >
             No recipients found for that search!
             No recipients found for that search!
           </td>
           </td>
@@ -465,6 +503,7 @@ export default {
         )
         )
         .then(({ data }) => {
         .then(({ data }) => {
           this.addRecipientLoading = false
           this.addRecipientLoading = false
+          data.data.key = this.recipients.length + 1
           this.recipients.push(data.data)
           this.recipients.push(data.data)
           this.reSort()
           this.reSort()
           this.newRecipient = ''
           this.newRecipient = ''