{mastodon api, twitter api}: make the follow handshake timeout configurable
This commit is contained in:
parent
7f530f6f80
commit
7b3fff9af8
@ -109,7 +109,8 @@ config :pleroma, :fe,
|
|||||||
config :pleroma, :activitypub,
|
config :pleroma, :activitypub,
|
||||||
accept_blocks: true,
|
accept_blocks: true,
|
||||||
unfollow_blocked: true,
|
unfollow_blocked: true,
|
||||||
outgoing_blocks: true
|
outgoing_blocks: true,
|
||||||
|
follow_handshake_timeout: 500
|
||||||
|
|
||||||
config :pleroma, :user, deny_follow_blocked: true
|
config :pleroma, :user, deny_follow_blocked: true
|
||||||
|
|
||||||
|
@ -571,11 +571,15 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
|||||||
end
|
end
|
||||||
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
|
def follow(%{assigns: %{user: follower}} = conn, %{"id" => id}) do
|
||||||
with %User{} = followed <- Repo.get(User, id),
|
with %User{} = followed <- Repo.get(User, id),
|
||||||
{:ok, follower} <- User.maybe_direct_follow(follower, followed),
|
{:ok, follower} <- User.maybe_direct_follow(follower, followed),
|
||||||
{:ok, _activity} <- ActivityPub.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})
|
render(conn, AccountView, "relationship.json", %{user: follower, target: followed})
|
||||||
else
|
else
|
||||||
{:error, message} ->
|
{:error, message} ->
|
||||||
|
@ -20,11 +20,15 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@activitypub Application.get_env(:pleroma, :activitypub)
|
||||||
|
@follow_handshake_timeout Keyword.get(@activitypub, :follow_handshake_timeout)
|
||||||
|
|
||||||
def follow(%User{} = follower, params) do
|
def follow(%User{} = follower, params) do
|
||||||
with {:ok, %User{} = followed} <- get_user(params),
|
with {:ok, %User{} = followed} <- get_user(params),
|
||||||
{:ok, follower} <- User.maybe_direct_follow(follower, followed),
|
{:ok, follower} <- User.maybe_direct_follow(follower, followed),
|
||||||
{:ok, activity} <- ActivityPub.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}
|
{:ok, follower, followed, activity}
|
||||||
else
|
else
|
||||||
err -> err
|
err -> err
|
||||||
|
Loading…
Reference in New Issue
Block a user