mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:39:28 +08:00
FIX: Serialize categories for group posts (#26663)
This is necessary when "lazy load categories" feature is enabled to make sure the categories are rendered for group posts.
This commit is contained in:
@ -196,7 +196,16 @@ class GroupsController < ApplicationController
|
||||
|
||||
posts =
|
||||
group.posts_for(guardian, params.permit(:before_post_id, :before, :category_id)).limit(20)
|
||||
render_serialized posts.to_a, GroupPostSerializer
|
||||
|
||||
response = { posts: serialize_data(posts, GroupPostSerializer) }
|
||||
|
||||
if guardian.can_lazy_load_categories?
|
||||
category_ids = posts.map { |p| p.topic.category_id }.compact.uniq
|
||||
categories = Category.secured(guardian).with_parents(category_ids)
|
||||
response[:categories] = serialize_data(categories, CategoryBadgeSerializer)
|
||||
end
|
||||
|
||||
render json: response
|
||||
end
|
||||
|
||||
def posts_feed
|
||||
|
Reference in New Issue
Block a user