+ defp build_attachments(activity) do
+ Enum.reduce(activity.data["object"]["attachment"], [], fn attachment, acc ->
+ rendered_tags =
+ Enum.map(attachment["url"], fn url ->
+ media_type =
+ Enum.find(["image", "audio", "video"], fn media_type ->
+ String.starts_with?(url["mediaType"], media_type)
+ end)
+
+ if media_type do
+ {:meta, [property: "og:" <> media_type, content: attachment_url(url["href"])], []}
+ else
+ nil
+ end
+ end)
+
+ Enum.reject(rendered_tags, &is_nil/1)
+ acc ++ rendered_tags
+ end)
+ end
+