Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
b836d3d1
Commit
b836d3d1
authored
Apr 20, 2020
by
lain
Browse files
ChatMessageValidator: Require `published` field
parent
139b9d13
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/activity_pub/builder.ex
View file @
b836d3d1
...
...
@@ -17,7 +17,8 @@ def create(actor, object_id, recipients) do
"actor"
=>
actor
.
ap_id
,
"to"
=>
recipients
,
"object"
=>
object_id
,
"type"
=>
"Create"
"type"
=>
"Create"
,
"published"
=>
DateTime
.
utc_now
()
|>
DateTime
.
to_iso8601
()
},
[]}
end
...
...
@@ -28,7 +29,8 @@ def chat_message(actor, recipient, content) do
"actor"
=>
actor
.
ap_id
,
"type"
=>
"ChatMessage"
,
"to"
=>
[
recipient
],
"content"
=>
content
"content"
=>
content
,
"published"
=>
DateTime
.
utc_now
()
|>
DateTime
.
to_iso8601
()
},
[]}
end
...
...
lib/pleroma/web/activity_pub/object_validators/chat_message_validator.ex
View file @
b836d3d1
...
...
@@ -54,7 +54,7 @@ def changeset(struct, data) do
def
validate_data
(
data_cng
)
do
data_cng
|>
validate_inclusion
(
:type
,
[
"ChatMessage"
])
|>
validate_required
([
:id
,
:actor
,
:to
,
:type
,
:content
])
|>
validate_required
([
:id
,
:actor
,
:to
,
:type
,
:content
,
:published
])
|>
validate_length
(
:to
,
is:
1
)
|>
validate_length
(
:content
,
max:
Pleroma
.
Config
.
get
([
:instance
,
:remote_limit
]))
|>
validate_local_concern
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment