FEATURE: Show SMTP response on admin email sent list and rearrange columns (#17143)

Follow up to 4d3c1ceb44, this commit
shows the SMTP response in the admin email sent list and also moves the
topic/post link into a new column. Reply key is now in its own column.
This commit is contained in:
Martin Brennan 2022-08-03 08:11:54 +10:00 committed by GitHub
parent b16028bc79
commit d2ddb140dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 6 deletions

View File

@ -7,6 +7,7 @@
<th>{{i18n "admin.email.to_address"}}</th>
<th>{{i18n "admin.email.email_type"}}</th>
<th>{{i18n "admin.email.reply_key"}}</th>
<th>{{i18n "admin.email.post_link_with_smtp"}}</th>
</tr>
</thead>
<tbody>
@ -16,6 +17,7 @@
<td><TextField @value={{this.filter.address}} @placeholderKey="admin.email.logs.filters.address_placeholder" /></td>
<td><TextField @value={{this.filter.type}} @placeholderKey="admin.email.logs.filters.type_placeholder" /></td>
<td><TextField @value={{this.filter.reply_key}} @placeholderKey="admin.email.logs.filters.reply_key_placeholder" /></td>
<td></td>
</tr>
{{#each this.model as |l|}}
@ -34,13 +36,14 @@
<a href="mailto:{{l.to_address}}">{{l.to_address}}</a>
</td>
<td class="sent-email-type">{{l.email_type}}</td>
<td class="sent-email-post-link">
<td class="sent-email-reply-key">
<span title={{l.reply_key}} class="reply-key">{{l.reply_key}}</span>
</td>
<td class="sent-email-post-link-with-smtp-response">
{{#if l.post_url}}
<a href={{l.post_url}}>{{l.post_description}}</a>
<span class="reply-key">{{l.reply_key}}</span>
{{else}}
<span class="reply-key">{{l.reply_key}}</span>
<a href={{l.post_url}}>{{l.post_description}}</a><br>
{{/if}}
<code title={{l.smtp_transaction_response}}>{{l.smtp_transaction_response}}</code>
</td>
</tr>
{{else}}

View File

@ -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);
}
}
}
}

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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