FEATURE: Add more control over post notices. (#7148)

FEATURE: Add more control over post notices. (#7148)

diff --git a/app/serializers/post_serializer.rb b/app/serializers/post_serializer.rb
index f345664..e06e067 100644
--- a/app/serializers/post_serializer.rb
+++ b/app/serializers/post_serializer.rb
@@ -370,7 +370,7 @@ class PostSerializer < BasicPostSerializer
   end
 
   def include_post_notice_type?
-    return false if scope.user&.id == object.user_id || !scope.user&.has_trust_level?(TrustLevel[2])
+    return false if scope.user&.id == object.user_id || !scope.user&.has_trust_level?(SiteSetting.min_post_notice_tl)
 
     post_notice_type.present?
   end
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index feb1d29..4114136 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -1910,6 +1910,7 @@ en:
     max_allowed_message_recipients: "Maximum recipients allowed in a message."
     watched_words_regular_expressions: "Watched words are regular expressions."
 
+    min_post_notice_tl: "Minimum trust level required to see post notices."
     returning_users_days: "How many days should pass before a user is considered to be returning."
 
     default_email_digest_frequency: "How often users receive summary emails by default."
diff --git a/config/site_settings.yml b/config/site_settings.yml
index 7b0aeb8..dfac7fd 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -808,6 +808,9 @@ posting:
     default: false
     client: true
     shadowed_by_global: true
+  min_post_notice_tl:
+    default: 2
+    enum: "TrustLevelSetting"
   returning_users_days:
     default: 60
 
diff --git a/spec/serializers/post_serializer_spec.rb b/spec/serializers/post_serializer_spec.rb
index 649f1ec..723ab53 100644
--- a/spec/serializers/post_serializer_spec.rb
+++ b/spec/serializers/post_serializer_spec.rb
@@ -194,8 +194,14 @@ describe PostSerializer do
     it "will not show for poster and TL2+ users" do
       expect(json_for_user(nil)[:post_notice_type]).to eq(nil)
       expect(json_for_user(user)[:post_notice_type]).to eq(nil)
+
+      SiteSetting.min_post_notice_tl = 2
       expect(json_for_user(user_tl1)[:post_notice_type]).to eq(nil)
       expect(json_for_user(user_tl2)[:post_notice_type]).to eq("returning")
+
+      SiteSetting.min_post_notice_tl = 1
+      expect(json_for_user(user_tl1)[:post_notice_type]).to eq("returning")
+      expect(json_for_user(user_tl2)[:post_notice_type]).to eq("returning")
     end
   end

GitHub sha: 7310ee3e