commit: 5062d24b30e471d3f3edbba837bd9142d80ecb62
parent 390caebd8800a06d1ee525a4844ae4ea08d2c2df
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Wed, 28 Jul 2021 01:15:41 +0200
"published"-related shenanigans
Diffstat:
4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/lib/pleroma/web/activity_pub/object_validators/announce_validator.ex b/lib/pleroma/web/activity_pub/object_validators/announce_validator.ex
@@ -68,7 +68,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AnnounceValidator do
defp validate_data(data_cng) do
data_cng
|> validate_inclusion(:type, ["Announce"])
- |> validate_required([:id, :type, :object, :actor, :to, :cc])
+ |> validate_required([:id, :type, :object, :actor, :to, :cc, :published])
|> validate_actor_presence()
|> validate_object_presence()
|> validate_existing_announce()
diff --git a/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex b/lib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex
@@ -114,7 +114,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidator do
defp validate_data(data_cng) do
data_cng
|> validate_inclusion(:type, ["Article", "Note", "Page"])
- |> validate_required([:id, :actor, :attributedTo, :type, :context, :context_id])
+ |> validate_required([:id, :actor, :attributedTo, :type, :context, :context_id, :published])
|> CommonValidations.validate_any_presence([:cc, :to])
|> CommonValidations.validate_fields_match([:actor, :attributedTo])
|> CommonValidations.validate_actor_presence()
diff --git a/lib/pleroma/web/activity_pub/object_validators/create_generic_validator.ex b/lib/pleroma/web/activity_pub/object_validators/create_generic_validator.ex
@@ -28,6 +28,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.CreateGenericValidator do
field(:bto, ObjectValidators.Recipients, default: [])
field(:bcc, ObjectValidators.Recipients, default: [])
field(:object, ObjectValidators.ObjectID)
+ field(:published, ObjectValidators.DateTime)
field(:expires_at, ObjectValidators.DateTime)
# Should be moved to object, done for CommonAPI.Utils.make_context
diff --git a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs
@@ -1368,17 +1368,19 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
} do
user = insert(:user)
- result =
+ activity_res =
conn
|> assign(:user, user)
|> put_req_header("content-type", "application/activity+json")
|> post("/users/#{user.nickname}/outbox", activity)
|> json_response(201)
- assert Activity.get_by_ap_id(result["id"])
- assert result["object"]
- assert %Object{data: object} = Object.normalize(result["object"], fetch: false)
+ assert activity_res["object"]
+ assert %Activity{data: activity_get} = Activity.get_by_ap_id(activity_res["id"])
+ assert activity_get["published"]
+ assert %Object{data: object} = Object.normalize(activity_res["object"], fetch: false)
assert object["content"] == activity["object"]["content"]
+ assert object["published"]
end
test "it rejects anything beyond 'Note' creations", %{conn: conn, activity: activity} do