1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.Emoji do
10 def cast(data) when is_map(data) do
13 {name, uri} when is_binary(name) and is_binary(uri) ->
14 # based on ObjectValidators.Uri.cast()
15 case URI.parse(uri) do
16 %URI{host: nil} -> true
17 %URI{host: ""} -> true
18 %URI{scheme: scheme} when scheme in ["https", "http"] -> false
26 if has_invalid_emoji?, do: :error, else: {:ok, data}
29 def cast(_data), do: :error
31 def dump(data), do: {:ok, data}
33 def load(data), do: {:ok, data}