projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Create activity handling: Flip it and reverse it
[akkoma]
/
lib
/
pleroma
/
web
/
activity_pub
/
object_validators
/
types
/
object_id.ex
diff --git
a/lib/pleroma/web/activity_pub/object_validators/types/object_id.ex
b/lib/pleroma/web/activity_pub/object_validators/types/object_id.ex
index 8e70effe416d6cb230dbc63965f8964801497cd0..f71f763704be08664ec3b3b0c3461d7c6c008e9c 100644
(file)
--- a/
lib/pleroma/web/activity_pub/object_validators/types/object_id.ex
+++ b/
lib/pleroma/web/activity_pub/object_validators/types/object_id.ex
@@
-4,30
+4,20
@@
defmodule Pleroma.Web.ActivityPub.ObjectValidators.Types.ObjectID do
def type, do: :string
def cast(object) when is_binary(object) do
def type, do: :string
def cast(object) when is_binary(object) do
- with %URI{
- scheme: scheme,
- host: host
- }
- when scheme in ["https", "http"] and not is_nil(host) <-
- URI.parse(object) do
- {:ok, object}
- else
- _ ->
- :error
+ # Host has to be present and scheme has to be an http scheme (for now)
+ case URI.parse(object) do
+ %URI{host: nil} -> :error
+ %URI{host: ""} -> :error
+ %URI{scheme: scheme} when scheme in ["https", "http"] -> {:ok, object}
+ _ -> :error
end
end
def cast(%{"id" => object}), do: cast(object)
end
end
def cast(%{"id" => object}), do: cast(object)
- def cast(_) do
- :error
- end
+ def cast(_), do: :error
- def dump(data) do
- {:ok, data}
- end
+ def dump(data), do: {:ok, data}
- def load(data) do
- {:ok, data}
- end
+ def load(data), do: {:ok, data}
end
end