logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: b43c7afde686f0a46d1983f57024d6f91f15a056
parent c8d188ba094afbfcf657c01f6f5bffabd1942cb5
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed, 28 Jul 2021 01:15:41 +0200

"published"-related shenanigans

Diffstat:

Mlib/pleroma/web/activity_pub/object_validators/announce_validator.ex2+-
Mlib/pleroma/web/activity_pub/object_validators/article_note_page_validator.ex2+-
Mtest/pleroma/web/activity_pub/activity_pub_controller_test.exs10++++++----
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 @@ -1506,17 +1506,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