mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 19:23:37 +08:00
FEATURE: show raw email for replies/topics created via email
This commit is contained in:
parent
ab9a0235b4
commit
2131a37811
|
@ -0,0 +1,24 @@
|
|||
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||
|
||||
import ObjectController from 'discourse/controllers/object';
|
||||
|
||||
/**
|
||||
This controller handles displaying of raw email
|
||||
|
||||
@class RawEmailController
|
||||
@extends ObjectController
|
||||
@namespace Discourse
|
||||
@uses ModalFunctionality
|
||||
@module Discourse
|
||||
**/
|
||||
export default ObjectController.extend(ModalFunctionality, {
|
||||
raw_email: "",
|
||||
|
||||
loadEmail: function(postId) {
|
||||
var self = this;
|
||||
Discourse.Post.load(postId).then(function (result) {
|
||||
self.set("raw_email", result.get('raw_email'));
|
||||
});
|
||||
}
|
||||
|
||||
});
|
|
@ -73,6 +73,11 @@ Discourse.TopicRoute = Discourse.Route.extend({
|
|||
this.controllerFor('modal').set('modalClass', 'history-modal');
|
||||
},
|
||||
|
||||
showRawEmail: function(post) {
|
||||
Discourse.Route.showModal(this, 'raw-email', post);
|
||||
this.controllerFor('raw_email').loadEmail(post.get("id"));
|
||||
},
|
||||
|
||||
mergeTopic: function() {
|
||||
Discourse.Route.showModal(this, 'mergeTopic', this.modelFor('topic'));
|
||||
},
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<div class="modal-body">
|
||||
{{#if raw_email}}
|
||||
<pre><code>{{raw_email}}</code></pre>
|
||||
{{else}}
|
||||
Not Available!
|
||||
{{/if}}
|
||||
</div>
|
|
@ -53,7 +53,7 @@
|
|||
<div class="post-info wiki" title="{{i18n post.wiki.about}}" {{action "editPost" this}}><i class="fa fa-pencil-square-o"></i></div>
|
||||
{{/if}}
|
||||
{{#if via_email}}
|
||||
<div class="post-info via-email" title="{{i18n post.via_email}}"><i class="fa fa-envelope-o"></i></div>
|
||||
<div class="post-info via-email" title="{{i18n post.via_email}}" {{action "showRawEmail" this}}><i class="fa fa-envelope-o"></i></div>
|
||||
{{/if}}
|
||||
<div {{bind-attr class=":read-state read"}} title="{{i18n post.unread}}"><i class='fa fa-circle'></i></div>
|
||||
</div>
|
||||
|
|
9
app/assets/javascripts/discourse/views/raw-email.es6
Normal file
9
app/assets/javascripts/discourse/views/raw-email.es6
Normal file
|
@ -0,0 +1,9 @@
|
|||
export default Discourse.ModalBodyView.extend({
|
||||
templateName: 'modal/raw_email',
|
||||
title: I18n.t('raw_email'),
|
||||
|
||||
resizeModal: function(){
|
||||
var viewPortHeight = $(window).height();
|
||||
this.$(".modal-body").css("max-height", Math.floor(0.8 * viewPortHeight) + "px");
|
||||
}.on("didInsertElement")
|
||||
});
|
|
@ -122,13 +122,13 @@ aside.quote {
|
|||
|
||||
.post-info {
|
||||
&.wiki, &.via-email {
|
||||
cursor: pointer;
|
||||
margin-right: 5px;
|
||||
i.fa {
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
&.wiki {
|
||||
cursor: pointer;
|
||||
color: $wiki;
|
||||
}
|
||||
&.via-email {
|
||||
|
|
|
@ -606,6 +606,8 @@ end
|
|||
# version :integer default(1), not null
|
||||
# cook_method :integer default(1), not null
|
||||
# wiki :boolean default(FALSE), not null
|
||||
# via_email :boolean default(FALSE), not null
|
||||
# raw_email :text
|
||||
# baked_at :datetime
|
||||
# baked_version :integer
|
||||
# hidden_at :datetime
|
||||
|
|
|
@ -51,7 +51,8 @@ class PostSerializer < BasicPostSerializer
|
|||
:wiki,
|
||||
:user_custom_fields,
|
||||
:static_doc,
|
||||
:via_email
|
||||
:via_email,
|
||||
:raw_email
|
||||
|
||||
def topic_slug
|
||||
object.try(:topic).try(:slug)
|
||||
|
|
|
@ -1382,6 +1382,7 @@ en:
|
|||
users_lowercase: "users"
|
||||
category_title: "Category"
|
||||
history: "History"
|
||||
raw_email: "Raw Email"
|
||||
changed_by: "by {{author}}"
|
||||
|
||||
categories_list: "Categories List"
|
||||
|
|
5
db/migrate/20141015060145_add_raw_email_to_posts.rb
Normal file
5
db/migrate/20141015060145_add_raw_email_to_posts.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddRawEmailToPosts < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :posts, :raw_email, :text
|
||||
end
|
||||
end
|
|
@ -245,6 +245,7 @@ module Email
|
|||
def create_post(user, options)
|
||||
# Mark the reply as incoming via email
|
||||
options[:via_email] = true
|
||||
options[:raw_email] = @raw
|
||||
|
||||
creator = PostCreator.new(user, options)
|
||||
post = creator.create
|
||||
|
|
|
@ -223,7 +223,7 @@ class PostCreator
|
|||
reply_to_post_number: @opts[:reply_to_post_number])
|
||||
|
||||
# Attributes we pass through to the post instance if present
|
||||
[:post_type, :no_bump, :cooking_options, :image_sizes, :acting_user, :invalidate_oneboxes, :cook_method, :via_email].each do |a|
|
||||
[:post_type, :no_bump, :cooking_options, :image_sizes, :acting_user, :invalidate_oneboxes, :cook_method, :via_email, :raw_email].each do |a|
|
||||
post.send("#{a}=", @opts[a]) if @opts[a].present?
|
||||
end
|
||||
|
||||
|
|
|
@ -146,6 +146,7 @@ Pleasure to have you here!
|
|||
topic.posts.count.should == (start_count + 1)
|
||||
created_post = topic.posts.last
|
||||
created_post.via_email.should == true
|
||||
created_post.raw_email.should == fixture_file("emails/valid_reply.eml")
|
||||
created_post.cooked.strip.should == fixture_file("emails/valid_reply.cooked").strip
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user