mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 13:06:56 +08:00
Be more liberal when the similar content of the post to be saved turns out to be the same post
- instead of setting a random number, we actually store the post id in redis now - and when checking for matching recent post and it is the same, we allow it still Fixes the issue that we prevent a user from reverting to a previous state within the unique_posts_min time window.
This commit is contained in:
@ -101,12 +101,13 @@ class Post < ActiveRecord::Base
|
|||||||
|
|
||||||
def store_unique_post_key
|
def store_unique_post_key
|
||||||
if SiteSetting.unique_posts_mins > 0
|
if SiteSetting.unique_posts_mins > 0
|
||||||
$redis.setex(unique_post_key, SiteSetting.unique_posts_mins.minutes.to_i, "1")
|
$redis.setex(unique_post_key, SiteSetting.unique_posts_mins.minutes.to_i, id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def matches_recent_post?
|
def matches_recent_post?
|
||||||
$redis.exists(unique_post_key)
|
post_id = $redis.get(unique_post_key)
|
||||||
|
post_id != nil and post_id != id
|
||||||
end
|
end
|
||||||
|
|
||||||
def raw_hash
|
def raw_hash
|
||||||
|
Reference in New Issue
Block a user