Hi,
Not an expert – In a plugin, you can add the groups field to the post serializer, something like that:
add_to_serializer(
:post,
:groups
) { object.user&.groups }
However, keep in mind that, as it is, anyone can see what group a person is in.
That said, I believe that as long as you’re using a flair, the group’s name will be visible to anyone, regardless of the permissions.
You could also insert a new available_flairs field to return only the group’s flairs necessary fields:
add_to_serializer(:post, :available_flairs) do
flairs = Array(object.user&.groups&.map do |group|
next unless group.flair_url
{
id: group.id,
name: group.name,
url: group.flair_url,
bgColor: group.flair_bg_color,
color: group.flair_color
}
end).compact
flairs
end
I hope that helps. ![]()
