mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
clean up 'checked_for_custom_avatars' user history entries
This commit is contained in:
parent
9fcaf090ec
commit
c57a1b393f
4 changed files with 66 additions and 57 deletions
|
@ -26,9 +26,11 @@ class ComposerMessagesFinder
|
|||
|
||||
if count < SiteSetting.educate_until_posts
|
||||
education_posts_text = I18n.t('education.until_posts', count: SiteSetting.educate_until_posts)
|
||||
return {templateName: 'composer/education',
|
||||
wait_for_typing: true,
|
||||
body: PrettyText.cook(SiteText.text_for(education_key, education_posts_text: education_posts_text)) }
|
||||
return {
|
||||
templateName: 'composer/education',
|
||||
wait_for_typing: true,
|
||||
body: PrettyText.cook(SiteText.text_for(education_key, education_posts_text: education_posts_text))
|
||||
}
|
||||
end
|
||||
|
||||
nil
|
||||
|
@ -37,7 +39,11 @@ class ComposerMessagesFinder
|
|||
# New users have a limited number of replies in a topic
|
||||
def check_new_user_many_replies
|
||||
return unless replying? && @user.posted_too_much_in_topic?(@details[:topic_id])
|
||||
{templateName: 'composer/education', body: PrettyText.cook(I18n.t('education.too_many_replies', newuser_max_replies_per_topic: SiteSetting.newuser_max_replies_per_topic)) }
|
||||
|
||||
{
|
||||
templateName: 'composer/education',
|
||||
body: PrettyText.cook(I18n.t('education.too_many_replies', newuser_max_replies_per_topic: SiteSetting.newuser_max_replies_per_topic))
|
||||
}
|
||||
end
|
||||
|
||||
# Should a user be contacted to update their avatar?
|
||||
|
@ -49,14 +55,14 @@ class ComposerMessagesFinder
|
|||
# We don't notify users who have avatars or who have been notified already.
|
||||
return if @user.uploaded_avatar_id || UserHistory.exists_for_user?(@user, :notified_about_avatar)
|
||||
|
||||
# Finally, we don't check users whose avatars haven't been examined
|
||||
return unless UserHistory.exists_for_user?(@user, :checked_for_custom_avatar)
|
||||
|
||||
# If we got this far, log that we've nagged them about the avatar
|
||||
UserHistory.create!(action: UserHistory.actions[:notified_about_avatar], target_user_id: @user.id )
|
||||
|
||||
# Return the message
|
||||
{templateName: 'composer/education', body: PrettyText.cook(I18n.t('education.avatar', profile_path: "/users/#{@user.username_lower}")) }
|
||||
{
|
||||
templateName: 'composer/education',
|
||||
body: PrettyText.cook(I18n.t('education.avatar', profile_path: "/users/#{@user.username_lower}"))
|
||||
}
|
||||
end
|
||||
|
||||
# Is a user replying too much in succession?
|
||||
|
@ -87,10 +93,12 @@ class ComposerMessagesFinder
|
|||
target_user_id: @user.id,
|
||||
topic_id: @details[:topic_id] )
|
||||
|
||||
{templateName: 'composer/education',
|
||||
wait_for_typing: true,
|
||||
extraClass: 'urgent',
|
||||
body: PrettyText.cook(I18n.t('education.sequential_replies')) }
|
||||
{
|
||||
templateName: 'composer/education',
|
||||
wait_for_typing: true,
|
||||
extraClass: 'urgent',
|
||||
body: PrettyText.cook(I18n.t('education.sequential_replies'))
|
||||
}
|
||||
end
|
||||
|
||||
def check_dominating_topic
|
||||
|
@ -102,6 +110,7 @@ class ComposerMessagesFinder
|
|||
!UserHistory.exists_for_user?(@user, :notified_about_dominating_topic, topic_id: @details[:topic_id])
|
||||
|
||||
topic = Topic.find_by(id: @details[:topic_id])
|
||||
|
||||
return if topic.blank? ||
|
||||
topic.user_id == @user.id ||
|
||||
topic.posts_count < SiteSetting.summary_posts_required ||
|
||||
|
@ -117,11 +126,12 @@ class ComposerMessagesFinder
|
|||
target_user_id: @user.id,
|
||||
topic_id: @details[:topic_id])
|
||||
|
||||
|
||||
{templateName: 'composer/education',
|
||||
wait_for_typing: true,
|
||||
extraClass: 'urgent',
|
||||
body: PrettyText.cook(I18n.t('education.dominating_topic', percent: (ratio * 100).round)) }
|
||||
{
|
||||
templateName: 'composer/education',
|
||||
wait_for_typing: true,
|
||||
extraClass: 'urgent',
|
||||
body: PrettyText.cook(I18n.t('education.dominating_topic', percent: (ratio * 100).round))
|
||||
}
|
||||
end
|
||||
|
||||
def check_reviving_old_topic
|
||||
|
@ -136,20 +146,22 @@ class ComposerMessagesFinder
|
|||
topic.last_posted_at.nil? ||
|
||||
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)) }
|
||||
{
|
||||
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?
|
||||
return @details[:composerAction] == "createTopic"
|
||||
@details[:composerAction] == "createTopic"
|
||||
end
|
||||
|
||||
def replying?
|
||||
return @details[:composerAction] == "reply"
|
||||
@details[:composerAction] == "reply"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue