mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 02:48:28 +08:00
removes whitespaces and uses scope
This commit is contained in:
@ -4,6 +4,8 @@ class IncomingEmail < ActiveRecord::Base
|
|||||||
belongs_to :post
|
belongs_to :post
|
||||||
|
|
||||||
scope :errored, -> { where("NOT is_bounce AND error IS NOT NULL") }
|
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
|
end
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
|
@ -446,8 +446,8 @@ module Email
|
|||||||
incoming_emails = IncomingEmail
|
incoming_emails = IncomingEmail
|
||||||
.joins(:post)
|
.joins(:post)
|
||||||
.where('posts.topic_id = ?', email_log.topic_id)
|
.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}%")
|
.addressed_to(email_log.reply_key)
|
||||||
.where('incoming_emails.to_addresses ILIKE :email OR incoming_emails.cc_addresses ILIKE :email', email: "%#{user.email}%")
|
.addressed_to(user.email)
|
||||||
|
|
||||||
incoming_emails.each do |email|
|
incoming_emails.each do |email|
|
||||||
next unless contains_email_address?(email.to_addresses, user.email) ||
|
next unless contains_email_address?(email.to_addresses, user.email) ||
|
||||||
|
Reference in New Issue
Block a user