FEATURE: Warn when reviving a topic that has been inactive for X days. Setting warn_reviving_old_topic_age controls when the warning is shown. Set it to 0 to disable this feature.

This commit is contained in:
Neil Lalonde
2014-03-12 10:44:08 -04:00
parent 363fabd3e7
commit 659e7fa4ce
4 changed files with 72 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ class ComposerMessagesFinder
end
def find
check_reviving_old_topic ||
check_education_message ||
check_new_user_many_replies ||
check_avatar_notification ||
@@ -123,6 +124,21 @@ class ComposerMessagesFinder
body: PrettyText.cook(I18n.t('education.dominating_topic', percent: (ratio * 100).round)) }
end
def check_reviving_old_topic
return unless @details[:topic_id]
topic = Topic.where(id: @details[:topic_id]).first
return if topic.nil? ||
SiteSetting.warn_reviving_old_topic_age < 1 ||
topic.last_posted_at > SiteSetting.warn_reviving_old_topic_age.days.ago
{templateName: 'composer/education',
wait_for_typing: false,
extraClass: 'urgent',
body: PrettyText.cook(I18n.t('education.reviving_old_topic', days: (Time.zone.now - topic.last_posted_at).round / 1.day)) }
end
private
def creating_topic?