FIX: Posts with Staff Colors were excluded from the group activity

Now they are included, with the correct color applied.
This commit is contained in:
Robin Ward
2020-12-10 14:55:53 -05:00
parent 820b3e672a
commit a51a06115a
5 changed files with 20 additions and 3 deletions

View File

@ -1,10 +1,17 @@
import Component from "@ember/component"; import Component from "@ember/component";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import getURL from "discourse-common/lib/get-url"; import getURL from "discourse-common/lib/get-url";
import { propertyEqual } from "discourse/lib/computed";
export default Component.extend({ export default Component.extend({
classNameBindings: [":user-stream-item", ":item", "moderatorAction"],
@discourseComputed("post.url") @discourseComputed("post.url")
postUrl(url) { postUrl(url) {
return getURL(url); return getURL(url);
}, },
moderatorAction: propertyEqual(
"post.post_type",
"site.post_types.moderator_action"
),
}); });

View File

@ -1,7 +1,7 @@
{{#load-more selector=".user-stream-item" action=(action "loadMore")}} {{#load-more selector=".user-stream-item" action=(action "loadMore")}}
<div class="user-stream"> <div class="user-stream">
{{#each model as |post|}} {{#each model as |post|}}
{{group-post post=post class="user-stream-item item"}} {{group-post post=post}}
{{else}} {{else}}
<div>{{i18n emptyText}}</div> <div>{{i18n emptyText}}</div>
{{/each}} {{/each}}

View File

@ -303,7 +303,7 @@ class Group < ActiveRecord::Base
.where(groups: { id: id }) .where(groups: { id: id })
.where('topics.archetype <> ?', Archetype.private_message) .where('topics.archetype <> ?', Archetype.private_message)
.where('topics.visible') .where('topics.visible')
.where(post_type: Post.types[:regular]) .where(post_type: [Post.types[:regular], Post.types[:moderator_action]])
if opts[:category_id].present? if opts[:category_id].present?
result = result.where('topics.category_id = ?', opts[:category_id].to_i) result = result.where('topics.category_id = ?', opts[:category_id].to_i)

View File

@ -11,7 +11,8 @@ class GroupPostSerializer < ApplicationSerializer
:url, :url,
:category_id, :category_id,
:post_number, :post_number,
:topic_id :topic_id,
:post_type
has_one :user, serializer: GroupPostUserSerializer, embed: :object has_one :user, serializer: GroupPostUserSerializer, embed: :object
has_one :topic, serializer: BasicTopicSerializer, embed: :object has_one :topic, serializer: BasicTopicSerializer, embed: :object

View File

@ -461,6 +461,15 @@ describe GroupsController do
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(response.parsed_body.first["id"]).to eq(post.id) expect(response.parsed_body.first["id"]).to eq(post.id)
end 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 end
describe "#members" do describe "#members" do