mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Show right message when permanently deleting topic (#14717)
This commit is contained in:
@@ -1755,6 +1755,15 @@ class Topic < ActiveRecord::Base
|
||||
).performed!
|
||||
end
|
||||
|
||||
def cannot_permanently_delete_reason(user)
|
||||
if self.posts_count > 0
|
||||
I18n.t('post.cannot_permanently_delete.many_posts')
|
||||
elsif self.deleted_by_id == user&.id && self.deleted_at >= Post::PERMANENT_DELETE_TIMER.ago
|
||||
time_left = RateLimiter.time_left(Post::PERMANENT_DELETE_TIMER.to_i - Time.zone.now.to_i + self.deleted_at.to_i)
|
||||
I18n.t('post.cannot_permanently_delete.wait_or_different_admin', time_left: time_left)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def invite_to_private_message(invited_by, target_user, guardian)
|
||||
@@ -1815,15 +1824,6 @@ class Topic < ActiveRecord::Base
|
||||
def apply_per_day_rate_limit_for(key, method_name)
|
||||
RateLimiter.new(user, "#{key}-per-day", SiteSetting.get(method_name), 1.day.to_i)
|
||||
end
|
||||
|
||||
def cannot_permanently_delete_reason(user)
|
||||
if self.posts_count > 1
|
||||
I18n.t('post.cannot_permanently_delete.many_posts')
|
||||
elsif self.deleted_by_id == user&.id && self.deleted_at >= Post::PERMANENT_DELETE_TIMER.ago
|
||||
time_left = RateLimiter.time_left(Post::PERMANENT_DELETE_TIMER.to_i - Time.zone.now.to_i + self.deleted_at.to_i)
|
||||
I18n.t('post.cannot_permanently_delete.wait_or_different_admin', time_left: time_left)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
|
||||
Reference in New Issue
Block a user