relay: fix invoking federator, use a timer to sleep the mix task to force a context...
authorWilliam Pitcock <nenolod@dereferenced.org>
Mon, 6 Aug 2018 07:27:11 +0000 (07:27 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 6 Aug 2018 08:22:12 +0000 (08:22 +0000)
lib/mix/tasks/relay_follow.ex
lib/mix/tasks/relay_unfollow.ex
lib/pleroma/web/activity_pub/relay.ex

index a8152d96fcad3732d33c5746b98351dac9e820a9..ac6f209241a4c2f83cd07d0fd261a250529d2e0a 100644 (file)
@@ -8,5 +8,8 @@ defmodule Mix.Tasks.RelayFollow do
     Mix.Task.run("app.start")
 
     :ok = Relay.follow(target)
+
+    # put this task to sleep to allow the genserver to push out the messages
+    :timer.sleep(500)
   end
 end
index 81b7197b2577125ab4a3c6ed570a05bd2fcb19cd..4621ace83944a6ee56b94889a524a6f52b7e0f30 100644 (file)
@@ -8,5 +8,8 @@ defmodule Mix.Tasks.RelayUnfollow do
     Mix.Task.run("app.start")
 
     :ok = Relay.unfollow(target)
+
+    # put this task to sleep to allow the genserver to push out the messages
+    :timer.sleep(500)
   end
 end
index 8b49188fbee76b29f744b3b92d2aa2beb1cb2ec1..29ece7f1bb75aad0f6e97fffb8aef2d11411613d 100644 (file)
@@ -11,7 +11,6 @@ defmodule Pleroma.Web.ActivityPub.Relay do
     with %User{} = local_user <- get_actor(),
          %User{} = target_user <- User.get_or_fetch_by_ap_id(target_instance),
          {:ok, activity} <- ActivityPub.follow(local_user, target_user) do
-      ActivityPub.publish(local_user, activity)
       Logger.info("relay: followed instance: #{target_instance}; id=#{activity.data["id"]}")
     else
       e -> Logger.error("error: #{inspect(e)}")
@@ -24,7 +23,6 @@ defmodule Pleroma.Web.ActivityPub.Relay do
     with %User{} = local_user <- get_actor(),
          %User{} = target_user <- User.get_or_fetch_by_ap_id(target_instance),
          {:ok, activity} <- ActivityPub.unfollow(local_user, target_user) do
-      ActivityPub.publish(local_user, activity)
       Logger.info("relay: unfollowed instance: #{target_instance}: id=#{activity.data["id"]}")
     else
       e -> Logger.error("error: #{inspect(e)}")