Mastodon StatusView: Return correct visibility.

This commit is contained in:
lain 2018-02-18 13:51:51 +01:00
parent 6ab0aba50a
commit 912ca56e59
1 changed files with 14 additions and 1 deletions

View File

@ -96,7 +96,7 @@ def render("status.json", %{activity: %{data: %{"object" => object}} = activity}
muted: false, muted: false,
sensitive: sensitive, sensitive: sensitive,
spoiler_text: object["summary"] || "", spoiler_text: object["summary"] || "",
visibility: "public", visibility: get_visibility(object),
media_attachments: attachments |> Enum.take(4), media_attachments: attachments |> Enum.take(4),
mentions: mentions, mentions: mentions,
tags: [], # fix, tags: [], # fix,
@ -109,7 +109,20 @@ def render("status.json", %{activity: %{data: %{"object" => object}} = activity}
} }
end 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"
[] == cc -> "direct"
true -> "private"
end
end
def render("attachment.json", %{attachment: attachment}) do def render("attachment.json", %{attachment: attachment}) do
IO.inspect(attachment)
[%{"mediaType" => media_type, "href" => href} | _] = attachment["url"] [%{"mediaType" => media_type, "href" => href} | _] = attachment["url"]
type = cond do type = cond do