aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2018-10-07 01:05:59 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2018-10-07 01:05:59 +0000
commit7b3fff9af87bbf8e6b0cc824b7ebf681e4a614f1 (patch)
tree38451b5c3f936b0e41d9ffbb6cfcf16b791be55c
parent7f530f6f8084b899b2fff40c074602e90d5fa35f (diff)
downloadpleroma-7b3fff9af87bbf8e6b0cc824b7ebf681e4a614f1.tar.gz
{mastodon api, twitter api}: make the follow handshake timeout configurable
-rw-r--r--config/config.exs3
-rw-r--r--lib/pleroma/web/mastodon_api/mastodon_api_controller.ex6
-rw-r--r--lib/pleroma/web/twitter_api/twitter_api.ex6
3 files changed, 12 insertions, 3 deletions
diff --git a/config/config.exs b/config/config.exs
index 608c035b0..c32ac9da2 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -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
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
index 9a470c364..499635a9d 100644
--- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
@@ -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} ->
diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex
index 3f0e2425c..3747285da 100644
--- a/lib/pleroma/web/twitter_api/twitter_api.ex
+++ b/lib/pleroma/web/twitter_api/twitter_api.ex
@@ -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