{mastodon api, twitter api}: make the follow handshake timeout configurable
authorWilliam Pitcock <nenolod@dereferenced.org>
Sun, 7 Oct 2018 01:05:59 +0000 (01:05 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sun, 7 Oct 2018 01:05:59 +0000 (01:05 +0000)
config/config.exs
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
lib/pleroma/web/twitter_api/twitter_api.ex

index 608c035b00b9ae2af84fdde1ca8fc67d2e3c5337..c32ac9da24aa5a6b64eb4fa6089aef46b811b016 100644 (file)
@@ -109,7 +109,8 @@ config :pleroma, :fe,
 config :pleroma, :activitypub,
   accept_blocks: true,
   unfollow_blocked: true,
-  outgoing_blocks: true
+  outgoing_blocks: true,
+  follow_handshake_timeout: 500
 
 config :pleroma, :user, deny_follow_blocked: true
 
index 9a470c36442f1f8e1a94a8ee7f2d30c7ea55d019..499635a9df8867d07cf0ce2dde258d58cd710265 100644 (file)
@@ -571,11 +571,15 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
     end
   end
 
+  @activitypub Application.get_env(:pleroma, :activitypub)
+  @follow_handshake_timeout Keyword.get(@activitypub, :follow_handshake_timeout)
+
   def follow(%{assigns: %{user: follower}} = conn, %{"id" => id}) do
     with %User{} = followed <- Repo.get(User, id),
          {:ok, follower} <- User.maybe_direct_follow(follower, followed),
          {:ok, _activity} <- ActivityPub.follow(follower, followed),
-         {:ok, follower, followed} <- User.wait_and_refresh(500, follower, followed) do
+         {:ok, follower, followed} <-
+           User.wait_and_refresh(@follow_handshake_timeout, follower, followed) do
       render(conn, AccountView, "relationship.json", %{user: follower, target: followed})
     else
       {:error, message} ->
index 3f0e2425c2b75bb0125101891a278914d384bd39..3747285da6a2f1c399ced77651649921f76689de 100644 (file)
@@ -20,11 +20,15 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
     end
   end
 
+  @activitypub Application.get_env(:pleroma, :activitypub)
+  @follow_handshake_timeout Keyword.get(@activitypub, :follow_handshake_timeout)
+
   def follow(%User{} = follower, params) do
     with {:ok, %User{} = followed} <- get_user(params),
          {:ok, follower} <- User.maybe_direct_follow(follower, followed),
          {:ok, activity} <- ActivityPub.follow(follower, followed),
-         {:ok, follower, followed} <- User.wait_and_refresh(500, follower, followed) do
+         {:ok, follower, followed} <-
+           User.wait_and_refresh(@follow_handshake_timeout, follower, followed) do
       {:ok, follower, followed, activity}
     else
       err -> err