mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 06:30:15 +08:00
6bbd83067d
* FEATURE: Add tl2 threshold for editing new posts * Adds a new setting and for tl2 editing posts (30 days same as old value) * Sets the tl0/tl1 editing period as 1 day * FIX: Spec uses wrong setting * Fix site setting on guardian spec * FIX: post editing period specs * Avoid shared examples * Use update_columns to avoid callbacks on user during tests
25 lines
459 B
Ruby
25 lines
459 B
Ruby
# frozen_string_literal: true
|
|
|
|
module LimitedEdit
|
|
extend ActiveSupport::Concern
|
|
|
|
def edit_time_limit_expired?(user)
|
|
time_limit = user_time_limit(user)
|
|
if created_at && time_limit > 0
|
|
created_at < time_limit.minutes.ago
|
|
else
|
|
false
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def user_time_limit(user)
|
|
if user.trust_level < 2
|
|
SiteSetting.post_edit_time_limit.to_i
|
|
else
|
|
SiteSetting.tl2_post_edit_time_limit.to_i
|
|
end
|
|
end
|
|
end
|