+ maybe_ap_id = URI.to_string(uri)
+
+ case Types.ObjectID.cast(maybe_ap_id) do
+ {:ok, ap_id} ->
+ {:ok, ap_id}
+
+ _ ->
+ case Pleroma.Web.WebFinger.finger(maybe_ap_id) do
+ %{"ap_id" => ap_id} -> {:ok, ap_id}
+ _ -> {:error, maybe_ap_id}
+ end
+ end