From bca4208dc5b03fa604d9a818170bcf67b19b2695 Mon Sep 17 00:00:00 2001 From: Colin Reeder Date: Sun, 25 Oct 2020 12:17:31 -0600 Subject: [PATCH] Fix is_public? for non-lists --- lib/federation/activity_pub/visibility.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/federation/activity_pub/visibility.ex b/lib/federation/activity_pub/visibility.ex index b8599e880..ed9c39d63 100644 --- a/lib/federation/activity_pub/visibility.ex +++ b/lib/federation/activity_pub/visibility.ex @@ -20,9 +20,12 @@ defmodule Mobilizon.Federation.ActivityPub.Visibility do def is_public?(%Activity{data: data}), do: is_public?(data) 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 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)}") + + defp make_list(data) when is_list(data), do: data + defp make_list(data), do: [data] end