From 2997fe1ba9bf47bf8f78eee471b1dda76426ac91 Mon Sep 17 00:00:00 2001 From: lain Date: Sun, 18 Feb 2018 15:04:26 +0100 Subject: [PATCH] CommonAPI: If no visibility is given, return parent visibility. --- lib/pleroma/web/common_api/common_api.ex | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/web/common_api/common_api.ex b/lib/pleroma/web/common_api/common_api.ex index b682f95bb..c6657b8e8 100644 --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@ -46,10 +46,17 @@ defmodule Pleroma.Web.CommonAPI do end end + def get_visibility(%{"visibility" => visibility}), do: visibility + def get_visibility(%{"in_reply_to_status_id" => status_id}) do + inReplyTo = get_replied_to_activity(status_id) + Pleroma.Web.MastodonAPI.StatusView.get_visibility(inReplyTo.data["object"]) + end + def get_visibility(_), do: "public" + @instance Application.get_env(:pleroma, :instance) @limit Keyword.get(@instance, :limit) def post(user, %{"status" => status} = data) do - visibility = data["visibility"] || "public" + visibility = get_visibility(data) with status <- String.trim(status), length when length in 1..@limit <- String.length(status), attachments <- attachments_from_ids(data["media_ids"]),