+ def entire_thread_visible_for_user?(%Activity{} = activity, %User{} = user) do
+ {:ok, %{rows: [[result]]}} =
+ Ecto.Adapters.SQL.query(Repo, "SELECT thread_visibility($1, $2)", [
+ user.ap_id,
+ activity.data["id"]
+ ])
+
+ result
+ end
+
+ def get_visibility(object) do
+ to = object.data["to"] || []
+ cc = object.data["cc"] || []
+
+ cond do
+ Pleroma.Constants.as_public() in to ->
+ "public"
+
+ Pleroma.Constants.as_public() in cc ->
+ "unlisted"
+
+ # this should use the sql for the object's activity
+ Enum.any?(to, &String.contains?(&1, "/followers")) ->
+ "private"
+
+ object.data["directMessage"] == true ->
+ "direct"
+
+ is_binary(object.data["listMessage"]) ->
+ "list"