common api: handle replying to orphaned threads
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 26 Aug 2018 22:37:36 +0000 (22:37 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sun, 26 Aug 2018 22:37:36 +0000 (22:37 +0000)
lib/pleroma/web/common_api/common_api.ex

index 3f18a68e8a9e527b723ac23625f3959c4a8d5788..475c180a12896d1e892c2d8c90cf1a03d8a332f3 100644 (file)
@@ -61,8 +61,13 @@ defmodule Pleroma.Web.CommonAPI do
       do: visibility
 
   def get_visibility(%{"in_reply_to_status_id" => status_id}) when not is_nil(status_id) do
-    inReplyTo = get_replied_to_activity(status_id)
-    Pleroma.Web.MastodonAPI.StatusView.get_visibility(inReplyTo.data["object"])
+    case get_replied_to_activity(status_id) do
+      nil ->
+        "public"
+
+      inReplyTo ->
+        Pleroma.Web.MastodonAPI.StatusView.get_visibility(inReplyTo.data["object"])
+    end
   end
 
   def get_visibility(_), do: "public"