FIX: Set unique post key for a user outside of transaction.

Previously, the Redis key was set within the transaction and the key
isn't deleted if the transaction is not successful.

Note that this isn't tested because we don't have a repro of what can
raise an error within the transaction.

https://meta.discourse.org/t/body-is-too-similar-to-what-you-previously-posted-even-when-previous-post-didnt-go-through/105436
This commit is contained in:
Guo Xiang Tan
2019-01-08 15:02:51 +08:00
parent 05c015d252
commit ec27db78be
2 changed files with 4 additions and 3 deletions

View File

@ -167,7 +167,6 @@ class PostCreator
create_topic
save_post
extract_links
store_unique_post_key
track_topic
update_topic_stats
update_topic_auto_close
@ -182,6 +181,7 @@ class PostCreator
end
if @post && errors.blank? && !@opts[:import_mode]
store_unique_post_key
# update counters etc.
@post.topic.reload