Prepare to drop EmailLog#topic_id.

This commit is contained in:
Guo Xiang Tan
2018-07-18 10:21:54 +08:00
parent dbfa491ee2
commit 3874d40910
4 changed files with 8 additions and 8 deletions

View File

@ -634,7 +634,7 @@ module Email
def forwarded_reply_key?(email_log, user)
incoming_emails = IncomingEmail
.joins(:post)
.where('posts.topic_id = ?', email_log.topic_id)
.where('posts.topic_id = ?', email_log.topic.id)
.addressed_to(email_log.reply_key)
.addressed_to_user(user)
.pluck(:to_addresses, :cc_addresses)

View File

@ -77,11 +77,9 @@ module Email
# always set a default Message ID from the host
@message.header['Message-ID'] = "<#{SecureRandom.uuid}@#{host}>"
if topic_id.present?
email_log.topic_id = topic_id
post = Post.find_by(id: post_id)
topic = Topic.find_by(id: topic_id)
if topic_id.present? && post_id.present?
post = Post.find_by(id: post_id, topic_id: topic_id)
topic = post.topic
first_post = topic.ordered_posts.first
topic_message_id = first_post.incoming_email&.message_id.present? ?