formatting
This commit is contained in:
parent
8ccd8e6586
commit
c6ef4a5dd3
|
@ -26,8 +26,10 @@ defmodule BallsPDS.Ecto.Schema.Agent do
|
|||
end
|
||||
|
||||
def get_by_acl(acl) when is_binary(acl) do
|
||||
query = from a in __MODULE__,
|
||||
query =
|
||||
from(a in __MODULE__,
|
||||
where: a.acl == ^acl
|
||||
)
|
||||
|
||||
Repo.one(query)
|
||||
end
|
||||
|
|
|
@ -51,16 +51,24 @@ defmodule BallsPDS.Ecto.Schema.CollectionObject do
|
|||
end
|
||||
|
||||
def delete_all(%Object{id: collection_id}, ids) when is_list(ids) do
|
||||
{object_ids, remote_ids} = ids |> Enum.map(&resolve_id/1) |> Enum.reduce({[], []}, fn
|
||||
nil, acc -> acc
|
||||
{object_ids, remote_ids} =
|
||||
ids
|
||||
|> Enum.map(&resolve_id/1)
|
||||
|> Enum.reduce({[], []}, fn
|
||||
nil, acc ->
|
||||
acc
|
||||
|
||||
object_id, {object_ids, remote_ids} when is_integer(object_id) -> {[object_id | object_ids], remote_ids}
|
||||
object_id, {object_ids, remote_ids} when is_integer(object_id) ->
|
||||
{[object_id | object_ids], remote_ids}
|
||||
|
||||
remote_id, {object_ids, remote_ids} when is_binary(remote_id) -> {object_ids, [remote_id | remote_ids]}
|
||||
remote_id, {object_ids, remote_ids} when is_binary(remote_id) ->
|
||||
{object_ids, [remote_id | remote_ids]}
|
||||
end)
|
||||
|
||||
from(co in __MODULE__,
|
||||
where: co.collection_id == ^collection_id and (co.object_id in ^object_ids or co.remote_id in ^remote_ids)
|
||||
where:
|
||||
co.collection_id == ^collection_id and
|
||||
(co.object_id in ^object_ids or co.remote_id in ^remote_ids)
|
||||
)
|
||||
|> Repo.delete_all()
|
||||
end
|
||||
|
|
|
@ -50,7 +50,8 @@ defmodule BallsPDS.Ecto.Schema.Object do
|
|||
defp validate_path(changeset, field) do
|
||||
validate_change(changeset, field, fn _, path ->
|
||||
case BallsPDS.Util.Util.is_valid_path?(path) do
|
||||
:ok -> []
|
||||
:ok ->
|
||||
[]
|
||||
|
||||
{:error, :invalid_char} ->
|
||||
[{field, "Invalid characters"}]
|
||||
|
|
|
@ -91,7 +91,9 @@ defmodule BallsPDS.Util.ACL do
|
|||
}
|
||||
}
|
||||
|
||||
graph = Enum.with_index(read_acls) |> Enum.map(fn {acl, i} ->
|
||||
graph =
|
||||
Enum.with_index(read_acls)
|
||||
|> Enum.map(fn {acl, i} ->
|
||||
make_read_authorization(path, acl, "#read_acl_#{i}")
|
||||
end)
|
||||
|
||||
|
|
|
@ -138,10 +138,12 @@ defmodule BallsPDS.WAC do
|
|||
end
|
||||
end
|
||||
|
||||
defp extract_key(controller, key = %{}, id) when is_binary(controller) and (is_binary(id) or is_nil(id)),
|
||||
defp extract_key(controller, key = %{}, id)
|
||||
when is_binary(controller) and (is_binary(id) or is_nil(id)),
|
||||
do: extract_key(controller, [key], id)
|
||||
|
||||
defp extract_key(controller, keys, id) when is_list(keys) and is_binary(controller) and (is_binary(id) or is_nil(id)) do
|
||||
defp extract_key(controller, keys, id)
|
||||
when is_list(keys) and is_binary(controller) and (is_binary(id) or is_nil(id)) do
|
||||
Enum.reduce_while(keys, nil, fn
|
||||
%{"controller" => ^controller, "publicKeyMultibase" => multikey, "id" => key_id}, _
|
||||
when is_binary(multikey) and is_binary(key_id) ->
|
||||
|
@ -165,6 +167,7 @@ defmodule BallsPDS.WAC do
|
|||
# Match the entire key id or else check if it's just a fragment.
|
||||
defp match_id?(key_id, test_id) when is_binary(key_id) and is_binary(test_id),
|
||||
do: key_id == test_id || String.ends_with?(key_id, "#" <> test_id)
|
||||
|
||||
# If no test id is passed then match whatever was passed.
|
||||
defp match_id?(key_id, nil) when is_binary(key_id), do: true
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue