Body is too similar to what you previously posted - even when previous post didn't go through

This is legit:

https://github.com/discourse/discourse/blob/a19170a4c2c37bb6f6ae9531fe4f925777f3e8d5/lib/post_creator.rb#L170-L170

We store the key in redis a bit too early which means that a whole slew of errors can mean we never roll back the redis key.

Additionally, looking at post creator there are conditions where it can raise and then this line never hits:

https://github.com/discourse/discourse/blob/a19170a4c2c37bb6f6ae9531fe4f925777f3e8d5/lib/post_creator.rb#L185-L185

So rolling back this redis set is a bit tricky cause we need to do it for 2 types of conditions (general error OR errors are not blank and the error is not the too similar one)

Additionally this does raise the point on review that #create can technically raise an exception which is a bit inconsistent.

@tgxworld can you add cleaning this up to your list?

5 Likes