diff --git a/app/assets/javascripts/discourse/controllers/raw-email.js.es6 b/app/assets/javascripts/discourse/controllers/raw-email.js.es6 new file mode 100644 index 00000000000..24fa2eb85b4 --- /dev/null +++ b/app/assets/javascripts/discourse/controllers/raw-email.js.es6 @@ -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')); + }); + } + +}); diff --git a/app/assets/javascripts/discourse/routes/topic_route.js b/app/assets/javascripts/discourse/routes/topic_route.js index a02a635bc67..23aab8a89d6 100644 --- a/app/assets/javascripts/discourse/routes/topic_route.js +++ b/app/assets/javascripts/discourse/routes/topic_route.js @@ -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')); }, diff --git a/app/assets/javascripts/discourse/templates/modal/raw_email.hbs b/app/assets/javascripts/discourse/templates/modal/raw_email.hbs new file mode 100644 index 00000000000..522602dfa92 --- /dev/null +++ b/app/assets/javascripts/discourse/templates/modal/raw_email.hbs @@ -0,0 +1,7 @@ + diff --git a/app/assets/javascripts/discourse/templates/post.hbs b/app/assets/javascripts/discourse/templates/post.hbs index f9bf8059de4..ee1c1a1022e 100644 --- a/app/assets/javascripts/discourse/templates/post.hbs +++ b/app/assets/javascripts/discourse/templates/post.hbs @@ -53,7 +53,7 @@
{{/if}} {{#if via_email}} -
+
{{/if}}
diff --git a/app/assets/javascripts/discourse/views/raw-email.es6 b/app/assets/javascripts/discourse/views/raw-email.es6 new file mode 100644 index 00000000000..fa6985e6fec --- /dev/null +++ b/app/assets/javascripts/discourse/views/raw-email.es6 @@ -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") +}); diff --git a/app/assets/stylesheets/common/base/topic-post.scss b/app/assets/stylesheets/common/base/topic-post.scss index 3cff7420815..d103304e0c8 100644 --- a/app/assets/stylesheets/common/base/topic-post.scss +++ b/app/assets/stylesheets/common/base/topic-post.scss @@ -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 { diff --git a/app/models/post.rb b/app/models/post.rb index 0d311af67d9..91c0de77ac2 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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 diff --git a/app/serializers/post_serializer.rb b/app/serializers/post_serializer.rb index 3ee7ba875c1..72bb4a7082e 100644 --- a/app/serializers/post_serializer.rb +++ b/app/serializers/post_serializer.rb @@ -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) diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 2730043d5a2..097e61ca5cd 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -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" diff --git a/db/migrate/20141015060145_add_raw_email_to_posts.rb b/db/migrate/20141015060145_add_raw_email_to_posts.rb new file mode 100644 index 00000000000..2c3b89b6d64 --- /dev/null +++ b/db/migrate/20141015060145_add_raw_email_to_posts.rb @@ -0,0 +1,5 @@ +class AddRawEmailToPosts < ActiveRecord::Migration + def change + add_column :posts, :raw_email, :text + end +end diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb index a007965130a..4ca8032cf21 100644 --- a/lib/email/receiver.rb +++ b/lib/email/receiver.rb @@ -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 diff --git a/lib/post_creator.rb b/lib/post_creator.rb index 2eb4d6c1b5a..ae1c6fc178f 100644 --- a/lib/post_creator.rb +++ b/lib/post_creator.rb @@ -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 diff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rb index c5e7c9c4fa3..f5484fa0bb5 100644 --- a/spec/components/email/receiver_spec.rb +++ b/spec/components/email/receiver_spec.rb @@ -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