Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33103332
event_validator.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
event_validator.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.Web.ActivityPub.ObjectValidators.EventValidator
do
use
Ecto.Schema
alias
Pleroma.Web.ActivityPub.ObjectValidators.CommonFixes
alias
Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
alias
Pleroma.Web.ActivityPub.Transmogrifier
import
Ecto.Changeset
@primary_key
false
@derive
Jason.Encoder
# Extends from NoteValidator
embedded_schema
do
quote
do
unquote
do
import
Elixir.Pleroma.Web.ActivityPub.ObjectValidators.CommonFields
message_fields
()
object_fields
()
status_object_fields
()
end
end
end
def
cast_and_apply
(
data
)
do
data
|>
cast_data
|>
apply_action
(
:insert
)
end
def
cast_and_validate
(
data
)
do
data
|>
cast_data
()
|>
validate_data
()
end
def
cast_data
(
data
)
do
%
__MODULE__
{}
|>
changeset
(
data
)
end
defp
fix
(
data
)
do
data
|>
CommonFixes
.
fix_actor
()
|>
CommonFixes
.
fix_object_defaults
()
|>
Transmogrifier
.
fix_emoji
()
end
def
changeset
(
struct
,
data
)
do
data
=
fix
(
data
)
struct
|>
cast
(
data
,
__schema__
(
:fields
)
--
[
:attachment
,
:tag
])
|>
cast_embed
(
:attachment
)
|>
cast_embed
(
:tag
)
end
defp
validate_data
(
data_cng
)
do
data_cng
|>
validate_inclusion
(
:type
,
[
"Event"
])
|>
validate_required
([
:id
,
:actor
,
:attributedTo
,
:type
,
:context
])
|>
CommonValidations
.
validate_any_presence
([
:cc
,
:to
])
|>
CommonValidations
.
validate_fields_match
([
:actor
,
:attributedTo
])
|>
CommonValidations
.
validate_actor_presence
()
|>
CommonValidations
.
validate_host_match
()
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Tue, Jan 20, 1:35 PM (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
928589
Default Alt Text
event_validator.ex (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment