ActivityPub: Federate reactions.
authorlain <lain@soykaf.club>
Mon, 30 Sep 2019 13:51:09 +0000 (15:51 +0200)
committerlain <lain@soykaf.club>
Mon, 30 Sep 2019 13:51:09 +0000 (15:51 +0200)
lib/pleroma/web/activity_pub/activity_pub.ex
test/web/activity_pub/activity_pub_test.exs

index 77fa23db461f7749bb41f3747c09608253b65cae..a6fb67a28f6ceb795904f2e8e2d10f5b0ae249e8 100644 (file)
@@ -313,7 +313,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
          Pleroma.Emoji.is_unicode_emoji?(emoji),
          reaction_data <- make_emoji_reaction_data(user, object, emoji, activity_id),
          {:ok, activity} <- insert(reaction_data, local),
-         {:ok, object} <- add_emoji_reaction_to_object(activity, object) do
+         {:ok, object} <- add_emoji_reaction_to_object(activity, object),
+         :ok <- maybe_federate(activity) do
       {:ok, activity, object}
     end
   end
index 3e6f389bc362e1fc664b86aad74cc8c59bb3395b..4dc7d96d284de783468f97d92e36f23dc2389e52 100644 (file)
@@ -727,6 +727,18 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
   end
 
   describe "react to an object" do
+    test_with_mock "sends an activity to federation", Pleroma.Web.Federator, [:passthrough], [] do
+      Pleroma.Config.put([:instance, :federating], true)
+      user = insert(:user)
+      reactor = insert(:user)
+      {:ok, activity} = CommonAPI.post(user, %{"status" => "YASSSS queen slay"})
+      assert object = Object.normalize(activity)
+
+      {:ok, reaction_activity, _object} = ActivityPub.react_with_emoji(reactor, object, "🔥")
+
+      assert called(Pleroma.Web.Federator.publish(reaction_activity))
+    end
+
     test "adds an emoji reaction activity to the db" do
       user = insert(:user)
       reactor = insert(:user)