FEATURE: Allow viewing of raw emails for reviewable queued posts (#7910)
If a post arrives via email but must be reviewed, we now show an icon that can be clicked to view the raw contents of the email. This is useful if Discourse's email parser is acting odd and the user reviewing the post wants to know what the original contents were before approving/rejecting the post.
This commit is contained in:
parent
8dd3cbfcb9
commit
e47e0af123
|
@ -0,0 +1,9 @@
|
|||
import showModal from "discourse/lib/show-modal";
|
||||
|
||||
export default Ember.Component.extend({
|
||||
actions: {
|
||||
showRawEmail() {
|
||||
showModal("raw-email").set("rawEmail", this.reviewable.payload.raw_email);
|
||||
}
|
||||
}
|
||||
});
|
|
@ -5,6 +5,11 @@
|
|||
</div>
|
||||
{{category-badge reviewable.category}}
|
||||
{{reviewable-tags tags=reviewable.payload.tags tagName=''}}
|
||||
{{#if reviewable.payload.via_email}}
|
||||
<a href {{action "showRawEmail"}} class='show-raw-email'>
|
||||
{{d-icon "far-envelope" title="post.via_email"}}
|
||||
</a>
|
||||
{{/if}}
|
||||
{{/reviewable-topic-link}}
|
||||
|
||||
<div class='post-contents-wrapper'>
|
||||
|
|
|
@ -364,6 +364,10 @@
|
|||
}
|
||||
|
||||
.reviewable-item {
|
||||
.show-raw-email {
|
||||
color: $primary-medium;
|
||||
font-size: $font-down-2;
|
||||
}
|
||||
.post-title {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,9 @@ class ReviewableQueuedPostSerializer < ReviewableSerializer
|
|||
:is_poll,
|
||||
:typing_duration_msecs,
|
||||
:composer_open_duration_msecs,
|
||||
:tags
|
||||
:tags,
|
||||
:via_email,
|
||||
:raw_email
|
||||
)
|
||||
|
||||
def reply_to_post_number
|
||||
|
|
|
@ -201,6 +201,8 @@ class NewPostManager
|
|||
%w(typing_duration_msecs composer_open_duration_msecs reply_to_post_number).each do |a|
|
||||
payload[a] = @args[a].to_i if @args[a]
|
||||
end
|
||||
payload[:via_email] = true if !!@args[:via_email]
|
||||
payload[:raw_email] = @args[:raw_email] if @args[:raw_email].present?
|
||||
|
||||
reviewable = ReviewableQueuedPost.new(
|
||||
created_by: @user,
|
||||
|
|
|
@ -407,4 +407,34 @@ describe NewPostManager do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "via email" do
|
||||
let(:manager) do
|
||||
NewPostManager.new(
|
||||
topic.user,
|
||||
raw: 'this is emailed content',
|
||||
topic_id: topic.id,
|
||||
via_email: true,
|
||||
raw_email: 'raw email contents'
|
||||
)
|
||||
end
|
||||
|
||||
before do
|
||||
SiteSetting.approve_post_count = 100
|
||||
topic.user.trust_level = 0
|
||||
end
|
||||
|
||||
it "will store via_email and raw_email in the enqueued post" do
|
||||
result = manager.perform
|
||||
expect(result.action).to eq(:enqueued)
|
||||
expect(result.reviewable).to be_present
|
||||
expect(result.reviewable.payload['via_email']).to eq(true)
|
||||
expect(result.reviewable.payload['raw_email']).to eq('raw email contents')
|
||||
|
||||
post = result.reviewable.perform(Discourse.system_user, :approve_post).created_post
|
||||
expect(post.via_email).to eq(true)
|
||||
expect(post.raw_email).to eq("raw email contents")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -49,6 +49,8 @@ describe ReviewableQueuedPostSerializer do
|
|||
|
||||
expect(payload['raw']).to eq('hello world post contents.')
|
||||
expect(payload['title']).to be_blank
|
||||
expect(payload['via_email']).to eq(true)
|
||||
expect(payload['raw_email']).to eq('store_me')
|
||||
expect(json[:topic_id]).to eq(reviewable.topic_id)
|
||||
expect(json[:topic_url]).to eq(reviewable.topic.url)
|
||||
expect(json[:can_edit]).to eq(true)
|
||||
|
|
Loading…
Reference in New Issue