FIX: when posts are moved to a message then small action post should not be publicly visible (#7085)
This fix is inspired from what we do in discourse-assigned plugin. https://github.com/discourse/discourse-assign/blob/master/lib/topic_assigner.rb#L184 https://github.com/discourse/discourse-assign/blob/master/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js.es6#L125-L133
This commit is contained in:
parent
bb5119b88f
commit
c02956e29c
|
@ -114,7 +114,8 @@ export default function transformPost(
|
||||||
postAtts.isAutoGenerated = post.is_auto_generated;
|
postAtts.isAutoGenerated = post.is_auto_generated;
|
||||||
postAtts.isModeratorAction = postType === postTypes.moderator_action;
|
postAtts.isModeratorAction = postType === postTypes.moderator_action;
|
||||||
postAtts.isWhisper = postType === postTypes.whisper;
|
postAtts.isWhisper = postType === postTypes.whisper;
|
||||||
postAtts.isSmallAction = postType === postTypes.small_action;
|
postAtts.isSmallAction =
|
||||||
|
postType === postTypes.small_action || post.action_code === "split_topic";
|
||||||
postAtts.canBookmark = !!currentUser;
|
postAtts.canBookmark = !!currentUser;
|
||||||
postAtts.canManage = currentUser && currentUser.get("canManageTopic");
|
postAtts.canManage = currentUser && currentUser.get("canManageTopic");
|
||||||
postAtts.canViewRawEmail =
|
postAtts.canViewRawEmail =
|
||||||
|
|
|
@ -208,9 +208,10 @@ class PostMover
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
post_type = @move_to_pm ? Post.types[:whisper] : Post.types[:small_action]
|
||||||
original_topic.add_moderator_post(
|
original_topic.add_moderator_post(
|
||||||
user, message,
|
user, message,
|
||||||
post_type: Post.types[:small_action],
|
post_type: post_type,
|
||||||
action_code: "split_topic",
|
action_code: "split_topic",
|
||||||
post_number: @first_post_number_moved
|
post_number: @first_post_number_moved
|
||||||
)
|
)
|
||||||
|
|
|
@ -619,7 +619,7 @@ describe PostMover do
|
||||||
|
|
||||||
old_message.reload
|
old_message.reload
|
||||||
move_message = old_message.posts.find_by(post_number: 2)
|
move_message = old_message.posts.find_by(post_number: 2)
|
||||||
expect(move_message.post_type).to eq(Post.types[:small_action])
|
expect(move_message.post_type).to eq(Post.types[:whisper])
|
||||||
expect(move_message.raw).to include("2 posts were split")
|
expect(move_message.raw).to include("2 posts were split")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -662,7 +662,7 @@ describe PostMover do
|
||||||
|
|
||||||
it "uses the correct small action post" do
|
it "uses the correct small action post" do
|
||||||
moved_to = personal_message.move_posts(admin, [p2.id], destination_topic_id: another_personal_message.id, archetype: "private_message")
|
moved_to = personal_message.move_posts(admin, [p2.id], destination_topic_id: another_personal_message.id, archetype: "private_message")
|
||||||
post = Post.find_by(topic_id: personal_message.id, post_type: Post.types[:small_action])
|
post = Post.find_by(topic_id: personal_message.id, post_type: Post.types[:whisper])
|
||||||
|
|
||||||
expected_text = I18n.t(
|
expected_text = I18n.t(
|
||||||
"move_posts.existing_message_moderator_post",
|
"move_posts.existing_message_moderator_post",
|
||||||
|
|
Loading…
Reference in New Issue