ChatMessageValidator: Require `published` field
This commit is contained in:
parent
139b9d1338
commit
b836d3d104
|
@ -17,7 +17,8 @@ def create(actor, object_id, recipients) do
|
||||||
"actor" => actor.ap_id,
|
"actor" => actor.ap_id,
|
||||||
"to" => recipients,
|
"to" => recipients,
|
||||||
"object" => object_id,
|
"object" => object_id,
|
||||||
"type" => "Create"
|
"type" => "Create",
|
||||||
|
"published" => DateTime.utc_now() |> DateTime.to_iso8601()
|
||||||
}, []}
|
}, []}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,7 +29,8 @@ def chat_message(actor, recipient, content) do
|
||||||
"actor" => actor.ap_id,
|
"actor" => actor.ap_id,
|
||||||
"type" => "ChatMessage",
|
"type" => "ChatMessage",
|
||||||
"to" => [recipient],
|
"to" => [recipient],
|
||||||
"content" => content
|
"content" => content,
|
||||||
|
"published" => DateTime.utc_now() |> DateTime.to_iso8601()
|
||||||
}, []}
|
}, []}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ def changeset(struct, data) do
|
||||||
def validate_data(data_cng) do
|
def validate_data(data_cng) do
|
||||||
data_cng
|
data_cng
|
||||||
|> validate_inclusion(:type, ["ChatMessage"])
|
|> 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(:to, is: 1)
|
||||||
|> validate_length(:content, max: Pleroma.Config.get([:instance, :remote_limit]))
|
|> validate_length(:content, max: Pleroma.Config.get([:instance, :remote_limit]))
|
||||||
|> validate_local_concern()
|
|> validate_local_concern()
|
||||||
|
|
Loading…
Reference in New Issue