signing_key: refactor nested case into with statement
Some checks are pending
ci/woodpecker/push/build-amd64 Pipeline is pending approval
ci/woodpecker/push/build-arm64 Pipeline is pending approval
ci/woodpecker/push/docs Pipeline is pending approval
ci/woodpecker/push/lint Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval
Some checks are pending
ci/woodpecker/push/build-amd64 Pipeline is pending approval
ci/woodpecker/push/build-arm64 Pipeline is pending approval
ci/woodpecker/push/docs Pipeline is pending approval
ci/woodpecker/push/lint Pipeline is pending approval
ci/woodpecker/push/test Pipeline is pending approval
The error branches were already effectively identical before. This change is purely cosmetic.
This commit is contained in:
parent
7583eceb38
commit
294de939cb
1 changed files with 16 additions and 23 deletions
|
@ -194,12 +194,10 @@ def get_or_fetch_by_key_id(key_id) do
|
||||||
"""
|
"""
|
||||||
def fetch_remote_key(key_id) do
|
def fetch_remote_key(key_id) do
|
||||||
Logger.debug("Fetching remote key: #{key_id}")
|
Logger.debug("Fetching remote key: #{key_id}")
|
||||||
resp = Pleroma.Object.Fetcher.fetch_and_contain_remote_object_from_id(key_id)
|
|
||||||
|
|
||||||
case resp do
|
with {:ok, _body} = resp <-
|
||||||
{:ok, _body} ->
|
Pleroma.Object.Fetcher.fetch_and_contain_remote_object_from_id(key_id),
|
||||||
case handle_signature_response(resp) do
|
{:ok, ap_id, public_key_pem} <- handle_signature_response(resp) do
|
||||||
{:ok, ap_id, public_key_pem} ->
|
|
||||||
Logger.debug("Fetched remote key: #{ap_id}")
|
Logger.debug("Fetched remote key: #{ap_id}")
|
||||||
# fetch the user
|
# fetch the user
|
||||||
{:ok, user} = User.get_or_fetch_by_ap_id(ap_id)
|
{:ok, user} = User.get_or_fetch_by_ap_id(ap_id)
|
||||||
|
@ -211,16 +209,11 @@ def fetch_remote_key(key_id) do
|
||||||
}
|
}
|
||||||
|
|
||||||
Repo.insert(key, on_conflict: :replace_all, conflict_target: :key_id)
|
Repo.insert(key, on_conflict: :replace_all, conflict_target: :key_id)
|
||||||
|
else
|
||||||
e ->
|
e ->
|
||||||
Logger.debug("Failed to fetch remote key: #{inspect(e)}")
|
Logger.debug("Failed to fetch remote key: #{inspect(e)}")
|
||||||
{:error, "Could not fetch key"}
|
{:error, "Could not fetch key"}
|
||||||
end
|
end
|
||||||
|
|
||||||
_ ->
|
|
||||||
Logger.debug("Failed to fetch remote key: #{inspect(resp)}")
|
|
||||||
{:error, "Could not fetch key"}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Take the response from the remote instance and extract the key details
|
# Take the response from the remote instance and extract the key details
|
||||||
|
|
Loading…
Reference in a new issue