diff options
author | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-02-25 17:58:15 +0300 |
---|---|---|
committer | Alexander Strizhakov <alex.strizhakov@gmail.com> | 2020-02-25 18:08:01 +0300 |
commit | 1c05ff7c06e281fe2abd05ff4969e30ec7268bb1 (patch) | |
tree | b7acaaa4b2689cf3c3b956e0a7efd0342bfcc8bc /lib | |
parent | 42f76306e7fe69fc51be00285a4fef8569f54989 (diff) | |
download | pleroma-relay-list-change-for-stable.tar.gz |
relay list shows hosts without accepted followrelay-list-change-for-stable
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mix/tasks/pleroma/relay.ex | 17 | ||||
-rw-r--r-- | lib/pleroma/activity.ex | 7 |
2 files changed, 20 insertions, 4 deletions
diff --git a/lib/mix/tasks/pleroma/relay.ex b/lib/mix/tasks/pleroma/relay.ex index a738fae75..0df6b53ff 100644 --- a/lib/mix/tasks/pleroma/relay.ex +++ b/lib/mix/tasks/pleroma/relay.ex @@ -53,10 +53,19 @@ defmodule Mix.Tasks.Pleroma.Relay do def run(["list"]) do start_pleroma() - with %User{following: following} = _user <- Relay.get_actor() do - following - |> Enum.map(fn entry -> URI.parse(entry).host end) - |> Enum.uniq() + with %User{following: following} = user <- Relay.get_actor() do + accepted = + following + |> Enum.map(fn entry -> URI.parse(entry).host end) + |> Enum.uniq() + + without_accept = + user + |> Pleroma.Activity.following_requests_for_actor() + |> Enum.map(fn a -> URI.parse(a.data["object"]).host <> " (no Accept received)" end) + |> Enum.uniq() + + (accepted ++ without_accept) |> Enum.each(&shell_info(&1)) else e -> shell_error("Error while fetching relay subscription list: #{inspect(e)}") diff --git a/lib/pleroma/activity.ex b/lib/pleroma/activity.ex index 2c04a26f9..1967cf868 100644 --- a/lib/pleroma/activity.ex +++ b/lib/pleroma/activity.ex @@ -268,6 +268,13 @@ defmodule Pleroma.Activity do |> where([a], fragment("? ->> 'state' = 'pending'", a.data)) end + def following_requests_for_actor(%Pleroma.User{ap_id: ap_id}) do + Queries.by_type("Follow") + |> where([a], fragment("?->>'state' = 'pending'", a.data)) + |> where([a], a.actor == ^ap_id) + |> Repo.all() + end + def restrict_deactivated_users(query) do deactivated_users = from(u in User.Query.build(deactivated: true), select: u.ap_id) |