activitypub: rework thread filtering for split object view
authorWilliam Pitcock <nenolod@dereferenced.org>
Thu, 29 Nov 2018 03:34:57 +0000 (03:34 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Tue, 4 Dec 2018 04:52:09 +0000 (04:52 +0000)
lib/pleroma/web/activity_pub/activity_pub.ex

index dcf670afb573ea5ded751f6672594bf88e1cd6ee..34a84b045326938fe89b7d5b5711d72d78f5d163 100644 (file)
@@ -799,18 +799,21 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
   # guard
   def entire_thread_visible_for_user?(nil, user), do: false
 
-  # child
+  # child / root
   def entire_thread_visible_for_user?(
-        %Activity{data: %{"object" => %{"inReplyTo" => parent_id}}} = tail,
+        %Activity{data: %{"object" => object_id}} = tail,
         user
-      )
-      when is_binary(parent_id) do
+      ) do
     parent = Activity.get_in_reply_to_activity(tail)
-    visible_for_user?(tail, user) && entire_thread_visible_for_user?(parent, user)
-  end
 
-  # root
-  def entire_thread_visible_for_user?(tail, user), do: visible_for_user?(tail, user)
+    cond do
+      !is_nil(parent) ->
+        visible_for_user?(tail, user) && entire_thread_visible_for_user?(parent, user)
+
+      true ->
+        visible_for_user?(tail, user)
+    end
+  end
 
   # filter out broken threads
   def contain_broken_threads(%Activity{} = activity, %User{} = user) do