Merge branch 'hotfix/delete-activities' into 'develop'
authorrinpatch <rinpatch@sdf.org>
Thu, 14 Mar 2019 17:49:00 +0000 (17:49 +0000)
committerrinpatch <rinpatch@sdf.org>
Thu, 14 Mar 2019 17:49:00 +0000 (17:49 +0000)
Fix delete activities not federating

See merge request pleroma/pleroma!933

1  2 
lib/pleroma/web/activity_pub/activity_pub.ex

index d5b03cd2488d47be265fb9474c7418426120a20f,96b774c2124bd7476d7f3f1c598484b84bde0163..70db419cad6cf400b92efb3d2fc1ea2a69e05634
@@@ -310,19 -309,18 +310,19 @@@ defmodule Pleroma.Web.ActivityPub.Activ
  
    def delete(%Object{data: %{"id" => id, "actor" => actor}} = object, local \\ true) do
      user = User.get_cached_by_ap_id(actor)
-     to = object.data["to"] || [] ++ object.data["cc"] || []
+     to = (object.data["to"] || []) ++ (object.data["cc"] || [])
  
 -    data = %{
 -      "type" => "Delete",
 -      "actor" => actor,
 -      "object" => id,
 -      "to" => to
 -    }
 -
 -    with {:ok, _} <- Object.delete(object),
 +    with {:ok, object, activity} <- Object.delete(object),
 +         data <- %{
 +           "type" => "Delete",
 +           "actor" => actor,
 +           "object" => id,
 +           "to" => to,
 +           "deleted_activity_id" => activity && activity.id
 +         },
           {:ok, activity} <- insert(data, local),
 -         # Changing note count prior to enqueuing federation task in order to avoid race conditions on updating user.info
 +         # Changing note count prior to enqueuing federation task in order to avoid
 +         # race conditions on updating user.info
           {:ok, _actor} <- decrease_note_count_if_public(user, object),
           :ok <- maybe_federate(activity) do
        {:ok, activity}