UX: Hide link to incoming email when there is no bounce key

UX: Hide link to incoming email when there is no bounce key

For example, webhooks mark email log entries as bounced without there ever being an incoming email.

diff --git a/app/assets/javascripts/admin/templates/email-bounced.hbs b/app/assets/javascripts/admin/templates/email-bounced.hbs
index bbb812b..e8c7f90 100644
--- a/app/assets/javascripts/admin/templates/email-bounced.hbs
+++ b/app/assets/javascripts/admin/templates/email-bounced.hbs
@@ -28,7 +28,11 @@
           {{/if}}
         </td>
         <td><a href='mailto:{{unbound l.to_address}}'>{{l.to_address}}</a></td>
-        <td><a {{action "showIncomingEmail" l.id}}>{{l.email_type}}</a></td>
+        {{#if l.has_bounce_key}}
+          <td><a {{action "showIncomingEmail" l.id}}>{{l.email_type}}</a></td>
+        {{else}}
+          <td>{{l.email_type}}</td>
+        {{/if}}
       </tr>
     {{else}}
       {{#unless loading}}
diff --git a/app/serializers/email_log_serializer.rb b/app/serializers/email_log_serializer.rb
index 75c7010..8b4897b 100644
--- a/app/serializers/email_log_serializer.rb
+++ b/app/serializers/email_log_serializer.rb
@@ -2,7 +2,8 @@ class EmailLogSerializer < ApplicationSerializer
   include EmailLogsMixin
 
   attributes :reply_key,
-             :bounced
+             :bounced,
+             :has_bounce_key
 
   has_one :user, serializer: BasicUserSerializer, embed: :objects
 
@@ -14,4 +15,8 @@ class EmailLogSerializer < ApplicationSerializer
   def reply_key
     @options[:reply_keys][[object.post_id, object.user_id]].delete("-")
   end
+
+  def has_bounce_key
+    object.bounce_key.present?
+  end
 end

GitHub sha: de011b53

1 Like