mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-17 11:48:52 +08:00
Removes duplication from LimitedEdit to see who can edit posts, and also removes the old trust level setting check since it's no longer necessary. Also make it so staff can always edit since can_edit_post? already has a staff escape hatch.
21 lines
487 B
Ruby
21 lines
487 B
Ruby
# frozen_string_literal: true
|
|
|
|
module LimitedEdit
|
|
extend ActiveSupport::Concern
|
|
|
|
def edit_time_limit_expired?(user)
|
|
return true if !user.guardian.trusted_with_post_edits?
|
|
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
|