From a51a06115a73d1ba9ca9a265f1a642637007bf85 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 10 Dec 2020 14:55:53 -0500 Subject: [PATCH] FIX: Posts with Staff Colors were excluded from the group activity Now they are included, with the correct color applied. --- .../javascripts/discourse/app/components/group-post.js | 7 +++++++ .../discourse/app/templates/group-activity-posts.hbs | 2 +- app/models/group.rb | 2 +- app/serializers/group_post_serializer.rb | 3 ++- spec/requests/groups_controller_spec.rb | 9 +++++++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/group-post.js b/app/assets/javascripts/discourse/app/components/group-post.js index 679f88ceff3..47c6a5245dc 100644 --- a/app/assets/javascripts/discourse/app/components/group-post.js +++ b/app/assets/javascripts/discourse/app/components/group-post.js @@ -1,10 +1,17 @@ import Component from "@ember/component"; import discourseComputed from "discourse-common/utils/decorators"; import getURL from "discourse-common/lib/get-url"; +import { propertyEqual } from "discourse/lib/computed"; export default Component.extend({ + classNameBindings: [":user-stream-item", ":item", "moderatorAction"], + @discourseComputed("post.url") postUrl(url) { return getURL(url); }, + moderatorAction: propertyEqual( + "post.post_type", + "site.post_types.moderator_action" + ), }); diff --git a/app/assets/javascripts/discourse/app/templates/group-activity-posts.hbs b/app/assets/javascripts/discourse/app/templates/group-activity-posts.hbs index f134929e6c3..8e833dc151e 100644 --- a/app/assets/javascripts/discourse/app/templates/group-activity-posts.hbs +++ b/app/assets/javascripts/discourse/app/templates/group-activity-posts.hbs @@ -1,7 +1,7 @@ {{#load-more selector=".user-stream-item" action=(action "loadMore")}}
{{#each model as |post|}} - {{group-post post=post class="user-stream-item item"}} + {{group-post post=post}} {{else}}
{{i18n emptyText}}
{{/each}} diff --git a/app/models/group.rb b/app/models/group.rb index f4fd4dceab3..4c601847ee0 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -303,7 +303,7 @@ class Group < ActiveRecord::Base .where(groups: { id: id }) .where('topics.archetype <> ?', Archetype.private_message) .where('topics.visible') - .where(post_type: Post.types[:regular]) + .where(post_type: [Post.types[:regular], Post.types[:moderator_action]]) if opts[:category_id].present? result = result.where('topics.category_id = ?', opts[:category_id].to_i) diff --git a/app/serializers/group_post_serializer.rb b/app/serializers/group_post_serializer.rb index 29584bb8a63..1176fc36094 100644 --- a/app/serializers/group_post_serializer.rb +++ b/app/serializers/group_post_serializer.rb @@ -11,7 +11,8 @@ class GroupPostSerializer < ApplicationSerializer :url, :category_id, :post_number, - :topic_id + :topic_id, + :post_type has_one :user, serializer: GroupPostUserSerializer, embed: :object has_one :topic, serializer: BasicTopicSerializer, embed: :object diff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rb index a977d77378d..e03d4482ebb 100644 --- a/spec/requests/groups_controller_spec.rb +++ b/spec/requests/groups_controller_spec.rb @@ -461,6 +461,15 @@ describe GroupsController do expect(response.status).to eq(200) expect(response.parsed_body.first["id"]).to eq(post.id) end + + it "returns moderator actions" do + sign_in(user) + post = Fabricate(:post, user: user, post_type: Post.types[:moderator_action]) + get "/groups/#{group.name}/posts.json" + + expect(response.status).to eq(200) + expect(response.parsed_body.first["id"]).to eq(post.id) + end end describe "#members" do