diff options
author | lain <lain@soykaf.club> | 2020-04-20 13:14:59 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-04-20 13:14:59 +0200 |
commit | b836d3d104f75841d71f9cf7c5c8cb5c07ba7294 (patch) | |
tree | eb1202e0eb0835847359fb49f841ccfa0065336d /lib | |
parent | 139b9d1338618aa0107c188a9a5505c6615768be (diff) | |
download | pleroma-b836d3d104f75841d71f9cf7c5c8cb5c07ba7294.tar.gz |
ChatMessageValidator: Require `published` field
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/activity_pub/builder.ex | 6 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/object_validators/chat_message_validator.ex | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/pleroma/web/activity_pub/builder.ex b/lib/pleroma/web/activity_pub/builder.ex index f0a6c1e1b..b67166a30 100644 --- a/lib/pleroma/web/activity_pub/builder.ex +++ b/lib/pleroma/web/activity_pub/builder.ex @@ -17,7 +17,8 @@ defmodule Pleroma.Web.ActivityPub.Builder 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 @@ defmodule Pleroma.Web.ActivityPub.Builder do "actor" => actor.ap_id, "type" => "ChatMessage", "to" => [recipient], - "content" => content + "content" => content, + "published" => DateTime.utc_now() |> DateTime.to_iso8601() }, []} end diff --git a/lib/pleroma/web/activity_pub/object_validators/chat_message_validator.ex b/lib/pleroma/web/activity_pub/object_validators/chat_message_validator.ex index 6e3477cd1..9b8262553 100644 --- a/lib/pleroma/web/activity_pub/object_validators/chat_message_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validators/chat_message_validator.ex @@ -54,7 +54,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ChatMessageValidator 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() |