A platform for community discussion. Free, open, simple.
DEV: remove educational tips and associated site settings (#33012)
David Battersby9613f657d0cd
diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 2c656fbca26..fd84125b09e 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -697,24 +697,6 @@ en:For more tips and advice on participating in our community, [check out our community guidelines](%{base_path}/guidelines).- avatar: |- ### How about a picture for your account?-- You’ve posted a few topics and replies, but your profile picture isn’t as unique as you are – it’s just a letter.-- Have you considered **[visiting your user profile](%{profile_path})** and uploading a picture that represents you?-- It’s easier to follow discussions and find interesting people in conversations when everyone has a unique profile picture!-- sequential_replies: |- ### Consider replying to several posts at once-- Rather than several replies to a topic in a row, please consider a single reply that includes quotes from previous posts or @name references.-- You can edit your previous reply to add a quote by highlighting text and selecting the <b>quote reply</b> button that appears.-- It’s easier for everyone to read topics that have fewer in-depth replies versus lots of small, individual replies.-dominating_topic: You've posted a lot in this topic! Consider giving others an opportunity to participate, too.get_a_room:@@ -726,13 +708,6 @@ en:too_many_replies: |New users are temporarily limited to %{newuser_max_replies_per_topic} replies in the same topic. Please consider visiting other topics to keep getting to know the community.- reviving_old_topic: |- ### Revive this topic?-- The last reply to this topic was **%{time_ago}**. Your reply will bump the topic to the top of its list and notify anyone previously involved in the conversation.-- Are you sure you want to continue this old conversation?-activerecord:attributes:category:@@ -2472,8 +2447,6 @@ en:allow_profile_backgrounds: "Allow users to upload profile backgrounds."- 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."-get_a_room_threshold: "Number of posts a user has to make to the same person in the same topic before being warned."dont_feed_the_trolls_threshold: "Number of flags from other users before being warned."@@ -2482,8 +2455,6 @@ en: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."-pm_warn_user_last_seen_months_ago: "When creating a new PM warn users when target recepient has not been seen more than n months ago."suppress_uncategorized_badge: "Don't show the badge for uncategorized topics in topic lists."@@ -2536,7 +2507,6 @@ en:show_time_gap_days: "If two posts are made this many days apart, display the time gap in the topic."short_progress_text_threshold: "After the number of posts in a topic goes above this number, the progress bar will only show the current post number. If you change the progress bar's width, you may need to change this value."default_code_lang: "Default programming language syntax highlighting applied to markdown code blocks (auto, text, ruby, python etc.). This value must also be present in the `highlighted languages` site setting."- warn_reviving_old_topic_age: "When someone starts replying to a topic where the last reply is older than this many days, a warning will be displayed. Disable by setting to 0."autohighlight_all_code: "Apply syntax highlighting to HTML-authored <code> blocks, even if they didn't specify a language. To configure markdown-authored code blocks, use the 'default code lang' setting."highlighted_languages: "Included syntax highlighting rules. (Warning: including too many languages may impact performance) see: <a href='https://highlightjs.org/demo/' target='_blank'>https://highlightjs.org/demo</a> for a demo"show_copy_button_on_codeblocks: "Add a button to codeblocks to copy the block contents to the user's clipboard."diff --git a/config/site_settings.yml b/config/site_settings.ymlindex 84977ff07d6..de3f0897339 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -1372,9 +1372,6 @@ posting:client: truedefault: "auto"area: "posts_and_topics"- warn_reviving_old_topic_age:- default: 180- area: "posts_and_topics"autohighlight_all_code:client: truedefault: false@@ -3283,9 +3280,6 @@ uncategorized:educate_until_posts:default: 2area: "users"- sequential_replies_threshold:- default: 2- area: "stats_and_thresholds"get_a_room_threshold:default: 3area: "stats_and_thresholds"@@ -3295,9 +3289,6 @@ uncategorized:dominating_topic_minimum_percent:default: 40area: "stats_and_thresholds"- disable_avatar_education_message:- default: false- area: "users"pm_warn_user_last_seen_months_ago:default: 24area: "users"diff --git a/lib/composer_messages_finder.rb b/lib/composer_messages_finder.rbindex 738052a1d1b..73be979b169 100644--- a/lib/composer_messages_finder.rb+++ b/lib/composer_messages_finder.rb@@ -74,83 +74,6 @@ class ComposerMessagesFinder}end- # Should a user be contacted to update their avatar?- def check_avatar_notification- # A user has to be basic at least to be considered for an avatar notification- return unless @user.has_trust_level?(TrustLevel[1])-- # We don't notify users who have avatars or who have been notified already.- if @user.uploaded_avatar_id || UserHistory.exists_for_user?(@user, :notified_about_avatar)- return- end-- # 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- if SiteSetting.disable_avatar_education_message ||- SiteSetting.discourse_connect_overrides_avatar ||- [email protected]_any_groups?(SiteSetting.uploaded_avatars_allowed_groups_map)- return- end-- # 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- {- id: "avatar",- templateName: "education",- body:- PrettyText.cook(- I18n.t(- "education.avatar",- profile_path: "/u/#{@user.username_lower}/preferences/account#profile-picture",- ),- ),- }- end-- # Is a user replying too much in succession?- def check_sequential_replies- return unless educate_reply?(:notified_about_sequential_replies)-- # Count the posts made by this user in the last day- recent_posts_user_ids =- Post- .where(topic_id: @details[:topic_id])- .where("created_at > ?", 1.day.ago)- .where(post_type: Post.types[:regular])- .order("created_at desc")- .limit(SiteSetting.sequential_replies_threshold)- .pluck(:user_id)-- # Did we get back as many posts as we asked for, and are they all by the current user?- if recent_posts_user_ids.size != SiteSetting.sequential_replies_threshold ||- recent_posts_user_ids.detect { |u| u != @user.id }- return- end-- # If we got this far, log that we've nagged them about the sequential replies- UserHistory.create!(- action: UserHistory.actions[:notified_about_sequential_replies],- target_user_id: @user.id,- topic_id: @details[:topic_id],- )-- {- id: "sequential_replies",- templateName: "education",- wait_for_typing: true,- extraClass: "education-message",- hide_if_whisper: true,- body: PrettyText.cook(I18n.t("education.sequential_replies")),- }- end-def check_dominating_topicreturn unless educate_reply?(:notified_about_dominating_topic)@@ -254,33 +177,6 @@ class ComposerMessagesFinder}end- def check_reviving_old_topic- return unless replying?- if @topic.nil? || SiteSetting.warn_reviving_old_topic_age < 1 || @topic.last_posted_at.nil? ||- @topic.last_posted_at > SiteSetting.warn_reviving_old_topic_age.days.ago- return- end-- {- id: "reviving_old",- templateName: "education",- wait_for_typing: false,- extraClass: "education-message",- body:- PrettyText.cook(- I18n.t(- "education.reviving_old_topic",- time_ago:- AgeWords.time_ago_in_words(- @topic.last_posted_at,- false,- scope: :"datetime.distance_in_words_verbose",- ),- ),- ),- }- end-def self.user_not_seen_in_a_while(usernames)User.where(username_lower: usernames)diff --git a/spec/lib/composer_messages_finder_spec.rb b/spec/lib/composer_messages_finder_spec.rbindex 1d9c09d7fb9..f8e775fd9cc 100644--- a/spec/lib/composer_messages_finder_spec.rb+++ b/spec/lib/composer_messages_finder_spec.rb@@ -11,10 +11,7 @@ RSpec.describe ComposerMessagesFinder doit "calls all the message finders" dofinder.expects(:check_education_message).oncefinder.expects(:check_new_user_many_replies).once- finder.expects(:check_avatar_notification).once- finder.expects(:check_sequential_replies).oncefinder.expects(:check_dominating_topic).once- finder.expects(:check_reviving_old_topic).oncefinder.expects(:check_get_a_room).oncefinder.findend@@ -98,146 +95,6 @@ RSpec.describe ComposerMessagesFinder doendend- describe ".check_avatar_notification" do- let(:finder) { ComposerMessagesFinder.new(user, composer_action: "createTopic") }- fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }-- context "with success" do- let!(:message) { finder.check_avatar_notification }-- it "returns an avatar upgrade message" do- expect(message).to be_present- end-- it "creates a notified_about_avatar log" do- expect(UserHistory.exists_for_user?(user, :notified_about_avatar)).to eq(true)- end- end-- it "doesn't return notifications for new users" do- user.trust_level = TrustLevel[0]- expect(finder.check_avatar_notification).to be_blank- end-- it "doesn't return notifications for users who have custom avatars" do- user.uploaded_avatar_id = 1- expect(finder.check_avatar_notification).to be_blank- end-- it "doesn't notify users who have been notified already" 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 'discourse_connect_overrides_avatar' setting is enabled" do- SiteSetting.discourse_connect_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- user.change_trust_level!(TrustLevel[3])-- SiteSetting.uploaded_avatars_allowed_groups = ""- expect(finder.check_avatar_notification).to be_blank-- SiteSetting.uploaded_avatars_allowed_groups = "13"- expect(finder.check_avatar_notification).to be_present- end- end-- describe ".check_sequential_replies" do- fab!(:user)- fab!(:topic)-- before do- SiteSetting.educate_until_posts = 10- user.stubs(:post_count).returns(11)-- freeze_time(5.minutes.ago) do- Fabricate(:post, topic: topic, user: user)- Fabricate(:post, topic: topic, user: user)- Fabricate(:post, topic: topic, user: user, post_type: Post.types[:small_action])- end-- SiteSetting.sequential_replies_threshold = 2- end-- it "does not give a message for new topics" do- finder = ComposerMessagesFinder.new(user, composer_action: "createTopic")- expect(finder.check_sequential_replies).to be_blank- end-- it "does not give a message without a topic id" do- expect(- ComposerMessagesFinder.new(user, composer_action: "reply").check_sequential_replies,- ).to be_blank- end-- context "with reply" do- let(:finder) do- ComposerMessagesFinder.new(user, composer_action: "reply", topic_id: topic.id)- end-- it "does not give a message to users who are still in the 'education' phase" do- user.stubs(:post_count).returns(9)- expect(finder.check_sequential_replies).to be_blank- end-- it "doesn't notify a user it has already notified about sequential replies" do- UserHistory.create!(- action: UserHistory.actions[:notified_about_sequential_replies],- target_user_id: user.id,- topic_id: topic.id,- )- expect(finder.check_sequential_replies).to be_blank- end-- it "will notify you if it hasn't in the current topic" do- UserHistory.create!(- action: UserHistory.actions[:notified_about_sequential_replies],- target_user_id: user.id,- topic_id: topic.id + 1,- )- expect(finder.check_sequential_replies).to be_present- end-- it "doesn't notify a user who has less than the `sequential_replies_threshold` threshold posts" do- SiteSetting.sequential_replies_threshold = 5- expect(finder.check_sequential_replies).to be_blank- end-- it "doesn't notify a user if another user posted" do- Fabricate(:post, topic: topic, user: Fabricate(:user))- expect(finder.check_sequential_replies).to be_blank- end-- it "doesn't notify in a message" do- Topic.any_instance.expects(:private_message?).returns(true)- expect(finder.check_sequential_replies).to be_blank- end-- context "with success" do- let!(:message) { finder.check_sequential_replies }-- it "returns a message" do- expect(message).to be_present- end-- it "creates a notified_about_sequential_replies log" do- expect(UserHistory.exists_for_user?(user, :notified_about_sequential_replies)).to eq(true)- end- end- end- end-describe ".check_dominating_topic" dofab!(:user)fab!(:topic)@@ -251,8 +108,6 @@ RSpec.describe ComposerMessagesFinder doFabricate(:post, topic: topic, user: user)Fabricate(:post, topic: topic, user: user)Fabricate(:post, topic: topic, user: Fabricate(:user))-- SiteSetting.sequential_replies_threshold = 2endit "does not give a message for new topics" do@@ -581,75 +436,6 @@ RSpec.describe ComposerMessagesFinder doendend- describe ".check_reviving_old_topic" do- fab!(:user)- fab!(:topic)-- it "does not give a message without a topic id" do- expect(- described_class.new(user, composer_action: "createTopic").check_reviving_old_topic,- ).to be_blank- expect(- described_class.new(user, composer_action: "reply").check_reviving_old_topic,- ).to be_blank- end-- context "with a reply" do- context "when warn_reviving_old_topic_age is 180 days" do- before { SiteSetting.warn_reviving_old_topic_age = 180 }-- it "does not notify if last post is recent" do- topic = Fabricate(:topic, last_posted_at: 1.hour.ago)- expect(- described_class.new(- user,- composer_action: "reply",- topic_id: topic.id,- ).check_reviving_old_topic,- ).to be_blank- end-- it "notifies if last post is old" do- topic = Fabricate(:topic, last_posted_at: 181.days.ago)- message =- described_class.new(- user,- composer_action: "reply",- topic_id: topic.id,- ).check_reviving_old_topic- expect(message).not_to be_blank- expect(message[:body]).to match(/6 months ago/)- end- end-- context "when warn_reviving_old_topic_age is 0" do- before { SiteSetting.warn_reviving_old_topic_age = 0 }-- it "does not notify if last post is new" do- topic = Fabricate(:topic, last_posted_at: 1.hour.ago)- expect(- described_class.new(- user,- composer_action: "reply",- topic_id: topic.id,- ).check_reviving_old_topic,- ).to be_blank- end-- it "does not notify if last post is old" do- topic = Fabricate(:topic, last_posted_at: 365.days.ago)- expect(- described_class.new(- user,- composer_action: "reply",- topic_id: topic.id,- ).check_reviving_old_topic,- ).to be_blank- end- end- end- end-context "when editing a post" dofab!(:user)fab!(:topic) { Fabricate(:post).topic }@@ -660,10 +446,7 @@ RSpec.describe ComposerMessagesFinder dolet(:edit_post_finder) { ComposerMessagesFinder.new(user, composer_action: "edit") }- before do- SiteSetting.disable_avatar_education_message = true- SiteSetting.educate_until_posts = 2- end+ before { SiteSetting.educate_until_posts = 2 }it "returns nothing even if it normally would" doexpect(edit_post_finder.find).to eq(nil)diff --git a/spec/requests/composer_messages_controller_spec.rb b/spec/requests/composer_messages_controller_spec.rbindex ad32c860d19..76e57abb7e7 100644--- a/spec/requests/composer_messages_controller_spec.rb+++ b/spec/requests/composer_messages_controller_spec.rb@@ -22,13 +22,11 @@ RSpec.describe ComposerMessagesController doendit "delegates args to the finder" do- user.user_stat.update!(post_count: 10)- SiteSetting.disable_avatar_education_message = true-get "/composer_messages.json", params: argsexpect(response.status).to eq(200)+json = response.parsed_body- expect(json["composer_messages"].first["id"]).to eq("reviving_old")+ expect(json["composer_messages"].first["id"]).to eq("education")endendenddiff --git a/spec/support/system_helpers.rb b/spec/support/system_helpers.rbindex e5085e31577..ed3229826e1 100644--- a/spec/support/system_helpers.rb+++ b/spec/support/system_helpers.rb@@ -66,7 +66,6 @@ module SystemHelpersSiteSetting.force_hostname = Capybara.server_hostSiteSetting.port = Capybara.server_portSiteSetting.external_system_avatars_enabled = false- SiteSetting.disable_avatar_education_message = trueSiteSetting.enable_user_tips = falseSiteSetting.splash_screen = falseSiteSetting.allowed_internal_hosts =