FIX: Post Mannager wasn't being used for email replies
This commit is contained in:
parent
1e36400021
commit
2cbcd15789
|
@ -1,3 +1,4 @@
|
|||
require_dependency 'new_post_manager'
|
||||
require 'email/html_cleaner'
|
||||
#
|
||||
# Handles an incoming message
|
||||
|
@ -196,19 +197,20 @@ module Email
|
|||
end
|
||||
|
||||
def create_new_topic
|
||||
post = create_post_with_attachments(@user,
|
||||
result = create_post_with_attachments(@user,
|
||||
raw: @body,
|
||||
title: @message.subject,
|
||||
category: @category_id)
|
||||
|
||||
topic_id = result.post.present? ? result.post.topic_id : nil
|
||||
EmailLog.create(
|
||||
email_type: "topic_via_incoming_email",
|
||||
to_address: @message.from.first, # pick from address because we want the user's email
|
||||
topic_id: post.topic.id,
|
||||
topic_id: topic_id,
|
||||
user_id: @user.id,
|
||||
)
|
||||
|
||||
post
|
||||
result
|
||||
end
|
||||
|
||||
def create_post_with_attachments(user, post_opts={})
|
||||
|
@ -253,14 +255,14 @@ module Email
|
|||
options[:via_email] = true
|
||||
options[:raw_email] = @raw
|
||||
|
||||
creator = PostCreator.new(user, options)
|
||||
post = creator.create
|
||||
manager = NewPostManager.new(user, options)
|
||||
result = manager.perform
|
||||
|
||||
if creator.errors.present?
|
||||
raise InvalidPost, creator.errors.full_messages.join("\n")
|
||||
if result.errors.present?
|
||||
raise InvalidPost, result.errors.full_messages.join("\n")
|
||||
end
|
||||
|
||||
post
|
||||
result
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue