+ application: %{
+ name: "Web",
+ website: nil
+ },
+ language: nil,
+ emojis: emojis
+ }
+ end
+
+ def get_visibility(object) do
+ public = "https://www.w3.org/ns/activitystreams#Public"
+ to = object["to"] || []
+ cc = object["cc"] || []
+ cond do
+ public in to -> "public"
+ public in cc -> "unlisted"
+ Enum.any?(to, &(String.contains?(&1, "/followers"))) -> "private"
+ true -> "direct"
+ end
+ end
+
+ def render("attachment.json", %{attachment: attachment}) do
+ [%{"mediaType" => media_type, "href" => href} | _] = attachment["url"]
+
+ type = cond do
+ String.contains?(media_type, "image") -> "image"
+ String.contains?(media_type, "video") -> "video"
+ String.contains?(media_type, "audio") -> "audio"
+ true -> "unknown"
+ end
+
+ << hash_id::signed-32, _rest::binary >> = :crypto.hash(:md5, href)
+
+ %{
+ id: to_string(attachment["id"] || hash_id),
+ url: MediaProxy.url(href),
+ remote_url: href,
+ preview_url: MediaProxy.url(href),
+ text_url: href,
+ type: type