mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Add created_via column to IncomingEmail (#11751)
This should make it easier to track down how the incoming email was created, which is one of four locations: The POP3 poller (which picks up reply via email replies) The admin email controller #handle_mail (which is where hosted mail is sent) The IMAP sync tool The group SMTP mailer, which sends emails when replying to IMAP topics, pre-emptively creating IncomingEmail records to avoid double syncing
This commit is contained in:
@@ -11,8 +11,8 @@ describe Email::Receiver do
|
||||
SiteSetting.alternative_reply_by_email_addresses = "alt+%{reply_key}@bar.com"
|
||||
end
|
||||
|
||||
def process(email_name)
|
||||
Email::Receiver.new(email(email_name)).process!
|
||||
def process(email_name, opts = {})
|
||||
Email::Receiver.new(email(email_name), opts).process!
|
||||
end
|
||||
|
||||
it "raises an EmptyEmailError when 'mail_string' is blank" do
|
||||
@@ -350,6 +350,13 @@ describe Email::Receiver do
|
||||
expect(topic.posts.last.raw).to eq("This is a **HTML** reply ;)")
|
||||
end
|
||||
|
||||
it "stores the created_via source against the incoming email" do
|
||||
process(:text_reply, source: :handle_mail)
|
||||
expect(IncomingEmail.last.created_via).to eq(IncomingEmail.created_via_types[:handle_mail])
|
||||
process(:text_and_html_reply, source: :imap)
|
||||
expect(IncomingEmail.last.created_via).to eq(IncomingEmail.created_via_types[:imap])
|
||||
end
|
||||
|
||||
it "automatically elides gmail quotes" do
|
||||
SiteSetting.always_show_trimmed_content = true
|
||||
expect { process(:gmail_html_reply) }.to change { topic.posts.count }
|
||||
|
||||
@@ -78,6 +78,8 @@ describe Imap::Sync do
|
||||
.and change { Post.where(post_type: Post.types[:regular]).count }.by(1)
|
||||
.and change { IncomingEmail.count }.by(1)
|
||||
|
||||
expect(IncomingEmail.last.created_via).to eq(IncomingEmail.created_via_types[:imap])
|
||||
|
||||
expect(group.imap_uid_validity).to eq(1)
|
||||
expect(group.imap_last_uid).to eq(100)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user