commit: 4d4bb24b82ba1910511d0bd41b7ec996cf69696a
parent f65f479fdc04d60d9708ec13bd33069c6dbe1659
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Wed, 28 Jul 2021 01:15:41 +0200
"published"-related shenanigans
Diffstat:
3 files changed, 8 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
@@ -70,7 +70,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
@@ -101,7 +101,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])
+ |> validate_required([:id, :actor, :attributedTo, :type, :context, :published])
|> CommonValidations.validate_any_presence([:cc, :to])
|> CommonValidations.validate_fields_match([:actor, :attributedTo])
|> CommonValidations.validate_actor_presence()
diff --git a/test/pleroma/web/activity_pub/activity_pub_controller_test.exs b/test/pleroma/web/activity_pub/activity_pub_controller_test.exs
@@ -1527,17 +1527,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