FIX: Disable notices for posts by anonymous.

FIX: Disable notices for posts by anonymous.

diff --git a/app/serializers/post_serializer.rb b/app/serializers/post_serializer.rb
index e06e067..9df5e31 100644
--- a/app/serializers/post_serializer.rb
+++ b/app/serializers/post_serializer.rb
@@ -370,7 +370,9 @@ class PostSerializer < BasicPostSerializer
   end
 
   def include_post_notice_type?
-    return false if scope.user&.id == object.user_id || !scope.user&.has_trust_level?(SiteSetting.min_post_notice_tl)
+    return false if !scope.user || !scope.user.id || scope.user.id == object.user_id ||
+                    !object.user || object.user.anonymous? ||
+                    !scope.user.has_trust_level?(SiteSetting.min_post_notice_tl)
 
     post_notice_type.present?
   end

GitHub sha: 476d0050

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there:

I think we should have a test for this.

1 Like

Followed-up in DEV: Add test for post notices. by udan11 · Pull Request #7352 · discourse/discourse · GitHub

2 Likes

This commit has been mentioned on Discourse Meta. There might be relevant details there:

1 Like