Pleroma.Config.Oban.warn()
Pleroma.Application.limiters_setup()
Application.put_env(:phoenix, :serve_endpoints, false, persistent: true)
- Finch.start_link(name: MyFinch)
+
+ proxy_url = Pleroma.Config.get([:http, :proxy_url])
+ proxy = Pleroma.HTTP.AdapterHelper.format_proxy(proxy_url)
+
+ finch_config =
+ [:http, :adapter]
+ |> Pleroma.Config.get([])
+ |> Pleroma.HTTP.AdapterHelper.maybe_add_proxy_pool(proxy)
+ |> Keyword.put(:name, MyFinch)
unless System.get_env("DEBUG") do
Logger.remove_backend(:console)
Pleroma.Emoji,
{Pleroma.Config.TransferTask, false},
Pleroma.Web.Endpoint,
+ {Finch, finch_config},
{Oban, oban_config},
{Majic.Pool,
[name: Pleroma.MajicPool, pool_size: Pleroma.Config.get([:majic_pool, :size], 2)]}
end
end
+ def run(["refetch_public_keys"]) do
+ start_pleroma()
+
+ Pleroma.User.Query.build(%{
+ external: true,
+ is_active: true
+ })
+ |> refetch_public_keys()
+ end
+
+ 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
{options, [], []} =
OptionParser.parse(rest,
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
|> validate_exclusion(:nickname, Config.get([User, :restricted_nicknames]))
|> validate_format(:nickname, local_nickname_regex())
|> put_ap_id()
+ |> put_keys()
|> unique_constraint(:ap_id)
|> put_following_and_follower_and_featured_address()
end
|> validate_length(:registration_reason, max: reason_limit)
|> maybe_validate_required_email(opts[:external])
|> put_password_hash
+ |> put_keys()
|> put_ap_id()
|> unique_constraint(:ap_id)
|> put_following_and_follower_and_featured_address()
end
end
+ def put_keys(changeset) do
+ {:ok, pem} = Keys.generate_rsa_pem()
+ put_change(changeset, :keys, pem)
+ end
+
def put_ap_id(changeset) do
ap_id = ap_id(%User{nickname: get_field(changeset, :nickname)})
put_change(changeset, :ap_id, ap_id)
assert changeset.valid?
end
- test "it sets the password_hash and ap_id" do
+ test "it sets the password_hash, ap_id and PEM key" do
changeset = User.register_changeset(%User{}, @full_user_data)
assert changeset.valid?
assert is_binary(changeset.changes[:password_hash])
assert changeset.changes[:ap_id] == User.ap_id(%User{nickname: @full_user_data.nickname})
+ assert is_binary(changeset.changes[:keys])
assert changeset.changes.follower_address == "#{changeset.changes.ap_id}/followers"
end