defp render_public_payload(%{"type" => "audio"} = post) do
DB.Search.Post.public_payload(post)
end
defp render_public_payload(%{"type" => "onDemand"} = post) do
DB.Search.Post.public_payload(post)
end
defp render_public_payload(%{"type" => "photo"} = post) do
DB.Search.Post.public_payload(post)
end
defp render_public_payload(%{"type" => "text"} = post) do
DB.Search.Post.public_payload(post)
end
defp render_public_payload(%{"type" => "video"} = post) do
DB.Search.Post.public_payload(post)
end
defp render_public_payload(%{"type" => "livestream"} = post) do
DB.Search.Post.public_payload(post)
end
Is there a way for me to simplify this code by pattern matching that `type is in a possible Enum of string values? How would you recommend I clean up these very similar functions?