From e65a7370ef94f926386a9552063fd159ad310d41 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Mon, 14 Dec 2015 22:32:40 +0530 Subject: [PATCH] FIX: disable avatar education message when 'allow_uploaded_avatars' is disabled FEATURE: setting to disable avatar education message --- config/locales/server.en.yml | 4 +++- config/site_settings.yml | 1 + lib/composer_messages_finder.rb | 6 ++++++ spec/components/composer_messages_finder_spec.rb | 16 +++++++++++++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 722726fef..e57f3965c 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1144,12 +1144,14 @@ en: allow_profile_backgrounds: "Allow users to upload profile backgrounds." - sequential_replies_threshold: "Number posts a user has to make in a row in a topic before being reminded about too many sequential replies. " + sequential_replies_threshold: "Number of posts a user has to make in a row in a topic before being reminded about too many sequential replies." enable_mobile_theme: "Mobile devices use a mobile-friendly theme, with the ability to switch to the full site. Disable this if you want to use a custom stylesheet that is fully responsive." dominating_topic_minimum_percent: "What percentage of posts a user has to make in a topic before being reminded about overly dominating a topic." + disable_avatar_education_message: "Disable education message for changing avatar." + daily_performance_report: "Analyze NGINX logs daily and post a Staff Only topic with details" suppress_uncategorized_badge: "Don't show the badge for uncategorized topics in topic lists." diff --git a/config/site_settings.yml b/config/site_settings.yml index 495dbadbd..4a6311860 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -954,6 +954,7 @@ uncategorized: educate_until_posts: 2 sequential_replies_threshold: 2 dominating_topic_minimum_percent: 20 + disable_avatar_education_message: false # Reporting daily_performance_report: false diff --git a/lib/composer_messages_finder.rb b/lib/composer_messages_finder.rb index ad1a30ca9..8dbf1f08b 100644 --- a/lib/composer_messages_finder.rb +++ b/lib/composer_messages_finder.rb @@ -56,6 +56,12 @@ 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) + # Do not notify user if any of the following is true: + # - "disable avatar education message" is enabled + # - "sso overrides avatar" is enabled + # - "allow uploaded avatars" is disabled + return if SiteSetting.disable_avatar_education_message || SiteSetting.sso_overrides_avatar || !SiteSetting.allow_uploaded_avatars + # 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 ) diff --git a/spec/components/composer_messages_finder_spec.rb b/spec/components/composer_messages_finder_spec.rb index efd13dc87..9e7c20c4c 100644 --- a/spec/components/composer_messages_finder_spec.rb +++ b/spec/components/composer_messages_finder_spec.rb @@ -109,6 +109,21 @@ describe ComposerMessagesFinder do UserHistory.create!(action: UserHistory.actions[:notified_about_avatar], target_user_id: user.id ) expect(finder.check_avatar_notification).to be_blank end + + it "doesn't notify users if 'disable_avatar_education_message' setting is enabled" do + SiteSetting.disable_avatar_education_message = true + expect(finder.check_avatar_notification).to be_blank + end + + it "doesn't notify users if 'sso_overrides_avatar' setting is enabled" do + SiteSetting.sso_overrides_avatar = true + expect(finder.check_avatar_notification).to be_blank + end + + it "doesn't notify users if 'allow_uploaded_avatars' setting is disabled" do + SiteSetting.allow_uploaded_avatars = false + expect(finder.check_avatar_notification).to be_blank + end end context '.check_sequential_replies' do @@ -313,4 +328,3 @@ describe ComposerMessagesFinder do end end -