From: lain Date: Sun, 18 Feb 2018 14:04:26 +0000 (+0100) Subject: CommonAPI: If no visibility is given, return parent visibility. X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=2997fe1ba9bf47bf8f78eee471b1dda76426ac91;p=akkoma CommonAPI: If no visibility is given, return parent visibility. --- 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"]),