Handle cases where a to/cc field is absent on a status
authorcsaurus <csaurus@mailbox.org>
Tue, 15 May 2018 01:46:09 +0000 (21:46 -0400)
committercsaurus <csaurus@mailbox.org>
Tue, 15 May 2018 01:54:25 +0000 (21:54 -0400)
lib/pleroma/web/activity_pub/activity_pub.ex

index f7f6d047e7a28f668dceaa156a35d0c7e1f41a56..4ce2e605266542888e64d7dd176f6b1737d31b15 100644 (file)
@@ -239,9 +239,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
       activity in query,
       join: sender in User,
       on: sender.ap_id == activity.actor,
+      # Are non-direct statuses with no to/cc possible?
       where:
-        fragment("not data->'to' \\? ?", ^public) and fragment("not data->'cc' \\? ?", ^public) and
-          fragment("not data->'to' \\? ?", sender.follower_address)
+        fragment("not coalesce(data->'to' \\? ?, false)", ^public) and
+          fragment("not coalesce(data->'cc' \\? ?, false)", ^public) and
+          fragment("not coalesce(data->'to' \\? ?, false)", sender.follower_address)
     )
   end