mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
removes whitespaces and uses scope
This commit is contained in:
parent
7370adeae3
commit
d3baae5365
@ -4,6 +4,8 @@ class IncomingEmail < ActiveRecord::Base
|
||||
belongs_to :post
|
||||
|
||||
scope :errored, -> { where("NOT is_bounce AND error IS NOT NULL") }
|
||||
|
||||
scope :addressed_to, -> (email) { where('incoming_emails.to_addresses ILIKE :email OR incoming_emails.cc_addresses ILIKE :email', email: "%#{email}%") }
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
|
@ -446,8 +446,8 @@ module Email
|
||||
incoming_emails = IncomingEmail
|
||||
.joins(:post)
|
||||
.where('posts.topic_id = ?', email_log.topic_id)
|
||||
.where('incoming_emails.to_addresses ILIKE :email OR incoming_emails.cc_addresses ILIKE :email', email: "%#{email_log.reply_key}%")
|
||||
.where('incoming_emails.to_addresses ILIKE :email OR incoming_emails.cc_addresses ILIKE :email', email: "%#{user.email}%")
|
||||
.addressed_to(email_log.reply_key)
|
||||
.addressed_to(user.email)
|
||||
|
||||
incoming_emails.each do |email|
|
||||
next unless contains_email_address?(email.to_addresses, user.email) ||
|
||||
|
@ -399,18 +399,18 @@ describe Email::Receiver do
|
||||
it "accepts emails with wrong reply key if the system knows about the forwareded email" do
|
||||
Fabricate(:incoming_email,
|
||||
raw: <<~RAW,
|
||||
Return-Path: <discourse@bar.com>
|
||||
From: Alice <discourse@bar.com>
|
||||
To: dave@bar.com, reply+4f97315cc828096c9cb34c6f1a0d6fe8@bar.com
|
||||
CC: carol@bar.com, bob@bar.com
|
||||
Subject: Hello world
|
||||
Date: Fri, 15 Jan 2016 00:12:43 +0100
|
||||
Message-ID: <10@foo.bar.mail>
|
||||
Mime-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
Return-Path: <discourse@bar.com>
|
||||
From: Alice <discourse@bar.com>
|
||||
To: dave@bar.com, reply+4f97315cc828096c9cb34c6f1a0d6fe8@bar.com
|
||||
CC: carol@bar.com, bob@bar.com
|
||||
Subject: Hello world
|
||||
Date: Fri, 15 Jan 2016 00:12:43 +0100
|
||||
Message-ID: <10@foo.bar.mail>
|
||||
Mime-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
|
||||
This post was created by email.
|
||||
This post was created by email.
|
||||
RAW
|
||||
from_address: "discourse@bar.com",
|
||||
to_addresses: "dave@bar.com;reply+4f97315cc828096c9cb34c6f1a0d6fe8@bar.com",
|
||||
|
Loading…
Reference in New Issue
Block a user