diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb index 8749745ddbb..c580b5ce1bf 100644 --- a/lib/email/receiver.rb +++ b/lib/email/receiver.rb @@ -93,6 +93,7 @@ module Email email_year = lines.each_with_index do |l, idx| break if l =~ /\A\s*\-{3,80}\s*\z/ || l =~ Regexp.new("\\A\\s*" + I18n.t('user_notifications.previous_discussion') + "\\s*\\Z") || + (l =~ /via #{SiteSetting.title}(.*)\:$/) || # This one might be controversial but so many reply lines have years, times and end with a colon. # Let's try it and see how well it works. (l =~ /\d{4}/ && l =~ /\d:\d\d/ && l =~ /\:$/) diff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rb index e50839a19c7..d999b773fef 100644 --- a/spec/components/email/receiver_spec.rb +++ b/spec/components/email/receiver_spec.rb @@ -50,6 +50,16 @@ stripped from my reply?") end end + describe "via" do + let(:wrote) { File.read("#{Rails.root}/spec/fixtures/emails/via_line.eml") } + let(:receiver) { Email::Receiver.new(wrote) } + + it "removes via lines if we know them" do + receiver.process + expect(receiver.body).to eq("Hello this email has content!") + end + end + describe "if wrote is on a second line" do let(:wrote) { File.read("#{Rails.root}/spec/fixtures/emails/multiline_wrote.eml") } let(:receiver) { Email::Receiver.new(wrote) } diff --git a/spec/fixtures/emails/via_line.eml b/spec/fixtures/emails/via_line.eml new file mode 100644 index 00000000000..31fe98d8c98 --- /dev/null +++ b/spec/fixtures/emails/via_line.eml @@ -0,0 +1,25 @@ + +Delivered-To: discourse-reply+cd480e301683c9902891f15968bf07a5@discourse.org +Received: by 10.194.216.104 with SMTP id op8csp80593wjc; + Wed, 24 Jul 2013 07:59:14 -0700 (PDT) +Return-Path: +References: <51efeb9b36c34_66dc2dfce6811866@discourse.mail> +From: Walter White +In-Reply-To: <51efeb9b36c34_66dc2dfce6811866@discourse.mail> +Mime-Version: 1.0 (1.0) +Date: Wed, 24 Jul 2013 15:59:10 +0100 +Message-ID: <4597127794206131679@unknownmsgid> +Subject: Re: [Discourse] new reply to your post in 'Crystal Blue' +To: walter via Discourse +Content-Type: multipart/alternative; boundary=001a11c20edc15a39304e2432790 + +Hello this email has content! + +codinghorror via Discourse wrote: +> [codinghorror] codinghorror +> +> August 7 +> +> It wouldn't be great at the moment for 100% email, since there's no +> way to be notified of new topics via email. (you can get notified of +> new replies to your posts and topics via email, and reply to them.)