ChatMessageValidator: Require `published` field
authorlain <lain@soykaf.club>
Mon, 20 Apr 2020 11:14:59 +0000 (13:14 +0200)
committerlain <lain@soykaf.club>
Mon, 20 Apr 2020 11:14:59 +0000 (13:14 +0200)
lib/pleroma/web/activity_pub/builder.ex
lib/pleroma/web/activity_pub/object_validators/chat_message_validator.ex

index f0a6c1e1b8eca57fa1a6f4b7eb0ce13413bf705e..b67166a30720e99c81cce7971e04b6d98223416d 100644 (file)
@@ -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
 
index 6e3477cd11c5ed551be695ac8ff95a99b2964388..9b8262553c553b7b9ecc6c2094c1720b280e25ba 100644 (file)
@@ -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()