mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 07:31:02 +08:00
FIX: Post Mannager wasn't being used for email replies
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
require_dependency 'new_post_manager'
|
||||||
require 'email/html_cleaner'
|
require 'email/html_cleaner'
|
||||||
#
|
#
|
||||||
# Handles an incoming message
|
# Handles an incoming message
|
||||||
@ -196,19 +197,20 @@ module Email
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_new_topic
|
def create_new_topic
|
||||||
post = create_post_with_attachments(@user,
|
result = create_post_with_attachments(@user,
|
||||||
raw: @body,
|
raw: @body,
|
||||||
title: @message.subject,
|
title: @message.subject,
|
||||||
category: @category_id)
|
category: @category_id)
|
||||||
|
|
||||||
|
topic_id = result.post.present? ? result.post.topic_id : nil
|
||||||
EmailLog.create(
|
EmailLog.create(
|
||||||
email_type: "topic_via_incoming_email",
|
email_type: "topic_via_incoming_email",
|
||||||
to_address: @message.from.first, # pick from address because we want the user's 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,
|
user_id: @user.id,
|
||||||
)
|
)
|
||||||
|
|
||||||
post
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_post_with_attachments(user, post_opts={})
|
def create_post_with_attachments(user, post_opts={})
|
||||||
@ -253,14 +255,14 @@ module Email
|
|||||||
options[:via_email] = true
|
options[:via_email] = true
|
||||||
options[:raw_email] = @raw
|
options[:raw_email] = @raw
|
||||||
|
|
||||||
creator = PostCreator.new(user, options)
|
manager = NewPostManager.new(user, options)
|
||||||
post = creator.create
|
result = manager.perform
|
||||||
|
|
||||||
if creator.errors.present?
|
if result.errors.present?
|
||||||
raise InvalidPost, creator.errors.full_messages.join("\n")
|
raise InvalidPost, result.errors.full_messages.join("\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
post
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user