FEATURE: Hide ignored user's Original Post content (#7113)

FEATURE: Hide ignored user’s Original Post content (#7113)

  • FEATURE: Hide ignored user’s Original Post content
diff --git a/app/assets/javascripts/discourse/lib/transform-post.js.es6 b/app/assets/javascripts/discourse/lib/transform-post.js.es6
index c0371aa..b63c224 100644
--- a/app/assets/javascripts/discourse/lib/transform-post.js.es6
+++ b/app/assets/javascripts/discourse/lib/transform-post.js.es6
@@ -80,6 +80,7 @@ export function transformBasicPost(post) {
     expandablePost: false,
     replyCount: post.reply_count,
     locked: post.locked,
+    ignored: post.ignored,
     userCustomFields: post.user_custom_fields
   };
 
diff --git a/app/assets/javascripts/discourse/widgets/post.js.es6 b/app/assets/javascripts/discourse/widgets/post.js.es6
index 5aa17d7..fbbda45 100644
--- a/app/assets/javascripts/discourse/widgets/post.js.es6
+++ b/app/assets/javascripts/discourse/widgets/post.js.es6
@@ -608,6 +608,9 @@ export default createWidget("post", {
     } else {
       classNames.push("regular");
     }
+    if (attrs.ignored) {
+      classNames.push("post-ignored");
+    }
     if (addPostClassesCallbacks) {
       for (let i = 0; i < addPostClassesCallbacks.length; i++) {
         let pluginClasses = addPostClassesCallbacks[i].call(this, attrs);
diff --git a/app/assets/stylesheets/common/base/topic-post.scss b/app/assets/stylesheets/common/base/topic-post.scss
index e17493e..91463df 100644
--- a/app/assets/stylesheets/common/base/topic-post.scss
+++ b/app/assets/stylesheets/common/base/topic-post.scss
@@ -214,6 +214,10 @@ aside.quote {
   margin: -2px;
 }
 
+.post-ignored {
+  font-style: italic;
+}
+
 .post-action {
   .undo-action,
   .act-action {
diff --git a/app/serializers/basic_post_serializer.rb b/app/serializers/basic_post_serializer.rb
index bcc75f7..014421d 100644
--- a/app/serializers/basic_post_serializer.rb
+++ b/app/serializers/basic_post_serializer.rb
@@ -6,7 +6,8 @@ class BasicPostSerializer < ApplicationSerializer
              :avatar_template,
              :created_at,
              :cooked,
-             :cooked_hidden
+             :cooked_hidden,
+             :ignored
 
   def name
     object.user && object.user.name
@@ -35,11 +36,18 @@ class BasicPostSerializer < ApplicationSerializer
       else
         I18n.t('flagging.user_must_edit')
       end
+    elsif ignored
+      I18n.t('ignored.hidden_content')
     else
       object.filter_quotes(@parent_post)
     end
   end
 
+  def ignored
+    object.is_first_post? && IgnoredUser.where(user_id: scope.current_user&.id,
+                                               ignored_user_id: object.user_id).present?
+  end
+
   def include_name?
     SiteSetting.enable_names?
   end
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index d1013cc..e578529 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -870,6 +870,9 @@ en:
     you_must_edit: '<p>Your post was flagged by the community. Please <a href="%{path}">see your messages</a>.</p>'
     user_must_edit: "<p>This post was flagged by the community and is temporarily hidden.</p>"
 
+  ignored:
+    hidden_content: '<p>Hidden content</p>'
+
   archetypes:
     regular:
       title: "Regular Topic"

GitHub sha: b58eea1f