diff --git a/app/assets/javascripts/admin/addon/templates/email-sent.hbs b/app/assets/javascripts/admin/addon/templates/email-sent.hbs
index ba28a0219e4..9f62aadc38f 100644
--- a/app/assets/javascripts/admin/addon/templates/email-sent.hbs
+++ b/app/assets/javascripts/admin/addon/templates/email-sent.hbs
@@ -7,6 +7,7 @@
{{i18n "admin.email.to_address"}} |
{{i18n "admin.email.email_type"}} |
{{i18n "admin.email.reply_key"}} |
+ {{i18n "admin.email.post_link_with_smtp"}} |
@@ -16,6 +17,7 @@
|
|
|
+ |
{{#each this.model as |l|}}
@@ -34,13 +36,14 @@
{{l.to_address}}
{{l.email_type}} |
-
+ |
+ {{l.reply_key}}
+ |
+
{{#if l.post_url}}
- {{l.post_description}}
- {{l.reply_key}}
- {{else}}
- {{l.reply_key}}
+ {{l.post_description}}
{{/if}}
+ {{l.smtp_transaction_response}}
|
{{else}}
diff --git a/app/assets/stylesheets/common/admin/emails.scss b/app/assets/stylesheets/common/admin/emails.scss
index 58d1720a7a1..0b6b9e76a24 100644
--- a/app/assets/stylesheets/common/admin/emails.scss
+++ b/app/assets/stylesheets/common/admin/emails.scss
@@ -105,3 +105,27 @@
font-family: monospace;
}
}
+
+.admin-email {
+ .email-list {
+ .sent-email-reply-key {
+ .reply-key {
+ word-break: break-word;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ width: 125px;
+ }
+ }
+
+ .sent-email-post-link-with-smtp-response {
+ width: 100%;
+ display: inline-block;
+ word-break: break-word;
+
+ code {
+ font-size: var(--font-down-2);
+ }
+ }
+ }
+}
diff --git a/app/controllers/admin/email_controller.rb b/app/controllers/admin/email_controller.rb
index 8d54a2b4e4f..b56f10f9f68 100644
--- a/app/controllers/admin/email_controller.rb
+++ b/app/controllers/admin/email_controller.rb
@@ -240,6 +240,11 @@ class Admin::EmailController < Admin::AdminController
logs = logs.where("users.username ILIKE ?", "%#{params[:user]}%") if params[:user].present?
logs = logs.where("#{table_name}.to_address ILIKE ?", "%#{params[:address]}%") if params[:address].present?
logs = logs.where("#{table_name}.email_type ILIKE ?", "%#{params[:type]}%") if params[:type].present?
+
+ if table_name == "email_logs" && params[:smtp_transaction_response].present?
+ logs = logs.where("#{table_name}.smtp_transaction_response ILIKE ?", "%#{params[:smtp_transaction_response]}%")
+ end
+
logs
end
diff --git a/app/serializers/email_log_serializer.rb b/app/serializers/email_log_serializer.rb
index 2744d19a317..803a55c2e56 100644
--- a/app/serializers/email_log_serializer.rb
+++ b/app/serializers/email_log_serializer.rb
@@ -5,7 +5,8 @@ class EmailLogSerializer < ApplicationSerializer
attributes :reply_key,
:bounced,
- :has_bounce_key
+ :has_bounce_key,
+ :smtp_transaction_response
has_one :user, serializer: BasicUserSerializer, embed: :objects
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 3bf0e5b6375..a41ac41bb29 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -4895,6 +4895,7 @@ en:
last_seen_user: "Last Seen User:"
no_result: "No results found for summary."
reply_key: "Reply Key"
+ post_link_with_smtp: "Post & SMTP Details"
skipped_reason: "Skip Reason"
incoming_emails:
from_address: "From"
@@ -4924,6 +4925,7 @@ en:
address_placeholder: "name@example.com"
type_placeholder: "digest, signup..."
reply_key_placeholder: "reply key"
+ smtp_transaction_response_placeholder: "SMTP ID"
moderation_history:
performed_by: "Performed By"
diff --git a/spec/requests/admin/email_controller_spec.rb b/spec/requests/admin/email_controller_spec.rb
index 7aae7eba1cc..8778f8cc964 100644
--- a/spec/requests/admin/email_controller_spec.rb
+++ b/spec/requests/admin/email_controller_spec.rb
@@ -84,6 +84,23 @@ RSpec.describe Admin::EmailController do
expect(logs.first["reply_key"]).to eq(post_reply_key_2.reply_key)
end
end
+
+ it 'should be able to filter by smtp_transaction_response' do
+ email_log_2 = Fabricate(:email_log, smtp_transaction_response: <<~RESPONSE)
+ 250 Ok: queued as pYoKuQ1aUG5vdpgh-k2K11qcpF4C1ZQ5qmvmmNW25SM=@mailhog.example
+ RESPONSE
+
+ get "/admin/email/sent.json", params: {
+ smtp_transaction_response: "pYoKu"
+ }
+
+ expect(response.status).to eq(200)
+
+ logs = response.parsed_body
+
+ expect(logs.size).to eq(1)
+ expect(logs.first["smtp_transaction_response"]).to eq(email_log_2.smtp_transaction_response)
+ end
end
describe '#skipped' do