A platform for community discussion. Free, open, simple.
FEATURE: allow disabling of anti spam profile hiding feature (#30508)
Sam9b9babdd7269
diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 458c7679462..0ea35cdbfe2 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -2432,6 +2432,7 @@ en:anonymous_account_duration_minutes: "To protect anonymity create a new anonymous account every N minutes for each user. Example: if set to 600, as soon as 600 minutes elapse from last post AND user switches to anon, a new anonymous account is created."hide_user_profiles_from_public: "Disable user cards, user profiles and user directory for anonymous users."+ hide_new_user_profiles: "Hide trust level 1 or lower user profiles from the public and trust level 1 users until they post for the first time. This feature is disabled unconditionally on must_approve_users and invite_only sites."allow_users_to_hide_profile: "Allow users to hide their profile and presence"hide_user_activity_tab: "Hide the activity tab on user profiles except for Admin and self."@@ -3212,6 +3213,7 @@ en:hide_suspension_reasons: ""hide_user_activity_tab: ""hide_user_profiles_from_public: ""+ hide_new_user_profiles: ""high_trust_flaggers_auto_hide_posts: ""highlighted_languages: ""history_hours_high: ""diff --git a/config/site_settings.yml b/config/site_settings.ymlindex 98f36030477..6f439651416 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -779,6 +779,8 @@ users:hide_user_profiles_from_public:default: falseclient: true+ hide_new_user_profiles:+ default: trueallow_featured_topic_on_user_profiles:default: trueclient: truediff --git a/lib/guardian/user_guardian.rb b/lib/guardian/user_guardian.rbindex 9c25c04367c..f3dbb8a5223 100644--- a/lib/guardian/user_guardian.rb+++ b/lib/guardian/user_guardian.rb@@ -134,12 +134,15 @@ module UserGuardianreturn true if user.staff? && !profile_hidden- if user.user_stat.blank? || user.user_stat.post_count == 0- return false if anonymous? || [email protected]_trust_level?(TrustLevel[2])- end+ if SiteSetting.hide_new_user_profiles && !SiteSetting.invite_only &&+ !SiteSetting.must_approve_users+ if user.user_stat.blank? || user.user_stat.post_count == 0+ return false if anonymous? || [email protected]_trust_level?(TrustLevel[2])+ end- if anonymous? || [email protected]_trust_level?(TrustLevel[1])- return user.has_trust_level?(TrustLevel[1]) && !profile_hidden+ if anonymous? || [email protected]_trust_level?(TrustLevel[1])+ return user.has_trust_level?(TrustLevel[1]) && !profile_hidden+ endend!profile_hiddendiff --git a/spec/lib/guardian/user_guardian_spec.rb b/spec/lib/guardian/user_guardian_spec.rbindex f5eb487b17d..6495af9b551 100644--- a/spec/lib/guardian/user_guardian_spec.rb+++ b/spec/lib/guardian/user_guardian_spec.rb@@ -107,6 +107,27 @@ RSpec.describe UserGuardian docontext "when viewing the profile of a user with 0 posts" dobefore { user.user_stat.update!(post_count: 0) }+ context "when hide_new_user_profiles is disabled" do+ it "allows anonymous to see any profile" do+ SiteSetting.hide_new_user_profiles = false+ expect(Guardian.new.can_see_profile?(user)).to eq(true)+ end+ end++ context "when site is invite only" do+ it "allows anonymous to see any profile" do+ SiteSetting.invite_only = true+ expect(Guardian.new.can_see_profile?(user)).to eq(true)+ end+ end++ context "when site requires user approval" do+ it "allows anonymous to see any profile" do+ SiteSetting.must_approve_users = true+ expect(Guardian.new.can_see_profile?(user)).to eq(true)+ end+ end+it "they can view their own profile" doexpect(Guardian.new(user).can_see_profile?(user)).to eq(true)end