mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2024-12-27 18:31:07 +00:00
Merge branch 'is_public-non-list' into 'master'
Fix is_public? for non-lists See merge request framasoft/mobilizon!647
This commit is contained in:
commit
9e5234059b
1 changed files with 4 additions and 1 deletions
|
@ -20,9 +20,12 @@ defmodule Mobilizon.Federation.ActivityPub.Visibility do
|
||||||
def is_public?(%Activity{data: data}), do: is_public?(data)
|
def is_public?(%Activity{data: data}), do: is_public?(data)
|
||||||
|
|
||||||
def is_public?(data) when is_map(data) do
|
def is_public?(data) when is_map(data) do
|
||||||
@public in (Map.get(data, "to", []) ++ Map.get(data, "cc", []))
|
@public in (make_list(Map.get(data, "to", [])) ++ make_list(Map.get(data, "cc", [])))
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_public?(%Comment{deleted_at: deleted_at}), do: !is_nil(deleted_at)
|
def is_public?(%Comment{deleted_at: deleted_at}), do: !is_nil(deleted_at)
|
||||||
def is_public?(err), do: raise(ArgumentError, message: "Invalid argument #{inspect(err)}")
|
def is_public?(err), do: raise(ArgumentError, message: "Invalid argument #{inspect(err)}")
|
||||||
|
|
||||||
|
defp make_list(data) when is_list(data), do: data
|
||||||
|
defp make_list(data), do: [data]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue