Merge remote-tracking branch 'upstream/develop' into feature/incoming-remote-unfollow
authorFrancis Dinh <normandy@firemail.cc>
Sun, 20 May 2018 23:17:15 +0000 (19:17 -0400)
committerFrancis Dinh <normandy@firemail.cc>
Sun, 20 May 2018 23:17:15 +0000 (19:17 -0400)
Fixed some conflicts in transmogrifier.ex

1  2 
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/transmogrifier.ex
lib/pleroma/web/activity_pub/utils.ex
test/web/activity_pub/transmogrifier_test.exs

index 47b84a469c121227779f7b2f6dcbb82976b1c454,a31452a638b25f4f710022a08d2d171239a47997..d92ca9b65d06f5b22651918a787363edf1dba403
@@@ -241,41 -241,27 +241,58 @@@ defmodule Pleroma.Web.ActivityPub.Trans
      end
    end
  
 +  def handle_incoming(
 +        %{
 +          "type" => "Undo",
 +          "object" => %{"type" => "Follow", "object" => followed},
 +          "actor" => follower,
 +          "id" => id
 +        } = data
 +      ) do
 +    with %User{local: true} = followed = User.get_cached_by_ap_id(followed),
 +         %User{} = follower = User.get_or_fetch_by_ap_id(follower),
 +         {:ok, activity} <- ActivityPub.unfollow(follower, followed, false) do
 +      User.unfollow(follower, followed)
 +      {:ok, activity}
 +    else
 +      e -> :error
 +    end
 +  end
 +
 +  def handle_incoming(
 +        %{"type" => "Block", "object" => blocked, "actor" => blocker, "id" => id} = data
 +      ) do
 +    with %User{local: true} = blocked = User.get_cached_by_ap_id(blocked),
 +         %User{} = blocker = User.get_or_fetch_by_ap_id(blocker),
 +         {:ok, activity} <- ActivityPub.block(blocker, blocked, false) do
 +      User.unfollow(blocker, blocked)
 +      User.block(blocker, blocked)
 +      {:ok, activity}
 +    else
 +      e -> :error
 +    end
 +  end
 +
+   def handle_incoming(
+         %{
+           "type" => "Undo",
+           "object" => %{"type" => "Like", "object" => object_id},
+           "actor" => actor,
+           "id" => id
+         } = data
+       ) do
+     with %User{} = actor <- User.get_or_fetch_by_ap_id(actor),
+          {:ok, object} <-
+            get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id),
+          {:ok, activity, _, _} <- ActivityPub.unlike(actor, object, id, false) do
+       {:ok, activity}
+     else
+       e -> :error
+     end
+   end
    # TODO
    # Accept
--  # Undo for non-Announce
  
    def handle_incoming(_), do: :error
  
Simple merge