Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33103335
emoji.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
899 B
Referenced Files
None
Subscribers
None
emoji.ex
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.EctoType.ActivityPub.ObjectValidators.Emoji
do
use
Ecto.Type
def
type
,
do
:
:map
def
cast
(
data
)
when
is_map
(
data
)
do
has_invalid_emoji?
=
Enum
.
find
(
data
,
fn
{
name
,
uri
}
when
is_binary
(
name
)
and
is_binary
(
uri
)
->
# based on ObjectValidators.Uri.cast()
case
URI
.
parse
(
uri
)
do
%
URI
{
host
:
nil
}
->
true
%
URI
{
host
:
""
}
->
true
%
URI
{
scheme
:
scheme
}
when
scheme
in
[
"https"
,
"http"
]
->
false
_
->
true
end
{
_name
,
_uri
}
->
true
end
)
if
has_invalid_emoji?
,
do
:
:error
,
else
:
{
:ok
,
data
}
end
def
cast
(
_data
),
do
:
:error
def
dump
(
data
),
do
:
{
:ok
,
data
}
def
load
(
data
),
do
:
{
:ok
,
data
}
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Tue, Jan 20, 1:36 PM (13 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
949821
Default Alt Text
emoji.ex (899 B)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment