mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Replying to deleted post via email should create new reply to topic
This commit is contained in:
@@ -596,12 +596,14 @@ module Email
|
|||||||
raise ReplyUserNotMatchingError, "post_reply_key.user_id => #{post_reply_key.user_id.inspect}, user.id => #{user.id.inspect}"
|
raise ReplyUserNotMatchingError, "post_reply_key.user_id => #{post_reply_key.user_id.inspect}, user.id => #{user.id.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
post = Post.with_deleted.find(post_reply_key.post_id)
|
||||||
|
|
||||||
create_reply(user: user,
|
create_reply(user: user,
|
||||||
raw: body,
|
raw: body,
|
||||||
elided: elided,
|
elided: elided,
|
||||||
hidden_reason_id: hidden_reason_id,
|
hidden_reason_id: hidden_reason_id,
|
||||||
post: post_reply_key.post,
|
post: post,
|
||||||
topic: post_reply_key.post.topic,
|
topic: post&.topic,
|
||||||
skip_validations: user.staged?)
|
skip_validations: user.staged?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -834,13 +836,14 @@ module Email
|
|||||||
|
|
||||||
def create_reply(options = {})
|
def create_reply(options = {})
|
||||||
raise TopicNotFoundError if options[:topic].nil? || options[:topic].trashed?
|
raise TopicNotFoundError if options[:topic].nil? || options[:topic].trashed?
|
||||||
|
options[:post] = nil if options[:post]&.trashed?
|
||||||
|
|
||||||
if post_action_type = post_action_for(options[:raw])
|
if post_action_type = post_action_for(options[:raw])
|
||||||
create_post_action(options[:user], options[:post], post_action_type)
|
create_post_action(options[:user], options[:post], post_action_type)
|
||||||
else
|
else
|
||||||
raise TopicClosedError if options[:topic].closed?
|
raise TopicClosedError if options[:topic].closed?
|
||||||
options[:topic_id] = options[:post].try(:topic_id)
|
options[:topic_id] = options[:topic].id
|
||||||
options[:reply_to_post_number] = options[:post].try(:post_number)
|
options[:reply_to_post_number] = options[:post]&.post_number
|
||||||
options[:is_group_message] = options[:topic].private_message? && options[:topic].allowed_groups.exists?
|
options[:is_group_message] = options[:topic].private_message? && options[:topic].allowed_groups.exists?
|
||||||
create_post_with_attachments(options)
|
create_post_with_attachments(options)
|
||||||
end
|
end
|
||||||
|
@@ -351,6 +351,12 @@ describe Email::Receiver do
|
|||||||
expect { process(:staged_reply_restricted) }.to change { topic.posts.count }
|
expect { process(:staged_reply_restricted) }.to change { topic.posts.count }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "posts a reply to the topic when the post was deleted" do
|
||||||
|
post.update_columns(deleted_at: 1.day.ago)
|
||||||
|
expect { process(:reply_user_matching) }.to change { topic.posts.count }
|
||||||
|
expect(topic.ordered_posts.last.reply_to_post_number).to be_nil
|
||||||
|
end
|
||||||
|
|
||||||
describe 'Unsubscribing via email' do
|
describe 'Unsubscribing via email' do
|
||||||
let(:last_email) { ActionMailer::Base.deliveries.last }
|
let(:last_email) { ActionMailer::Base.deliveries.last }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user