mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 17:55:14 +08:00
926d5f1c0a
Follow up to: 241d8f6452
22 lines
501 B
Ruby
22 lines
501 B
Ruby
# frozen_string_literal: true
|
|
|
|
module LimitedEdit
|
|
extend ActiveSupport::Concern
|
|
|
|
def edit_time_limit_expired?(user)
|
|
return true if user.trust_level < SiteSetting.min_trust_to_edit_post
|
|
time_limit = user_time_limit(user)
|
|
created_at && (time_limit > 0) && (created_at < time_limit.minutes.ago)
|
|
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
|