add refetch for specified users only
This commit is contained in:
parent
12274f8fb7
commit
8630cd93a2
1 changed files with 30 additions and 16 deletions
|
@ -258,29 +258,23 @@ def run(["untag", nickname | tags]) do
|
|||
end
|
||||
end
|
||||
|
||||
def run(["refetch_public_keys" | _rest]) do
|
||||
def run(["refetch_public_keys"]) do
|
||||
start_pleroma()
|
||||
|
||||
Pleroma.User.Query.build(%{
|
||||
external: true,
|
||||
is_active: true
|
||||
})
|
||||
|> Pleroma.Repo.chunk_stream(50, :batches)
|
||||
|> Stream.each(fn users ->
|
||||
users
|
||||
|> Enum.each(fn user ->
|
||||
IO.puts("Re-Resolving: #{user.ap_id}")
|
||||
|> refetch_public_keys()
|
||||
end
|
||||
|
||||
with {:ok, user} <- Pleroma.User.fetch_by_ap_id(user.ap_id),
|
||||
changeset <- Pleroma.User.update_changeset(user),
|
||||
{:ok, _user} <- Pleroma.User.update_and_set_cache(changeset) do
|
||||
:ok
|
||||
else
|
||||
error -> IO.puts("Could not resolve: #{user.ap_id}, #{inspect(error)}")
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|> Stream.run()
|
||||
def run(["refetch_public_keys" | rest]) do
|
||||
start_pleroma()
|
||||
|
||||
Pleroma.User.Query.build(%{
|
||||
ap_id: rest
|
||||
})
|
||||
|> refetch_public_keys()
|
||||
end
|
||||
|
||||
def run(["invite" | rest]) do
|
||||
|
@ -544,6 +538,26 @@ def run(["fix_follow_state", local_user, remote_user]) do
|
|||
end
|
||||
end
|
||||
|
||||
defp refetch_public_keys(query) do
|
||||
query
|
||||
|> Pleroma.Repo.chunk_stream(50, :batches)
|
||||
|> Stream.each(fn users ->
|
||||
users
|
||||
|> Enum.each(fn user ->
|
||||
IO.puts("Re-Resolving: #{user.ap_id}")
|
||||
|
||||
with {:ok, user} <- Pleroma.User.fetch_by_ap_id(user.ap_id),
|
||||
changeset <- Pleroma.User.update_changeset(user),
|
||||
{:ok, _user} <- Pleroma.User.update_and_set_cache(changeset) do
|
||||
:ok
|
||||
else
|
||||
error -> IO.puts("Could not resolve: #{user.ap_id}, #{inspect(error)}")
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|> Stream.run()
|
||||
end
|
||||
|
||||
defp set_moderator(user, value) do
|
||||
{:ok, user} =
|
||||
user
|
||||
|
|
Loading…
Reference in a new issue