diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bdc28dc6..53d978c91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - fixed later search result pages again fetching remote content - handle reports referring to a single plain id as their object; affected e.g. JSON-LD compacted reports without status references from Iceshrimp.NET +- fixed several issues parsing remote Question objects ### Changed - New installations (not existing instances) now default to the `simple` full-text-search config 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 index 8bc9bc98f..508b8c58e 100644 --- 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 @@ -179,7 +179,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidator do defp fix_content_map_languages(object), do: object - defp fix(data) do + def fix(data) do data |> CommonFixes.fix_actor() |> CommonFixes.fix_object_defaults() diff --git a/lib/pleroma/web/activity_pub/object_validators/question_validator.ex b/lib/pleroma/web/activity_pub/object_validators/question_validator.ex index de8c52c43..3c018ac55 100644 --- a/lib/pleroma/web/activity_pub/object_validators/question_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validators/question_validator.ex @@ -6,10 +6,9 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.QuestionValidator do use Ecto.Schema alias Pleroma.EctoType.ActivityPub.ObjectValidators - alias Pleroma.Web.ActivityPub.ObjectValidators.CommonFixes + alias Pleroma.Web.ActivityPub.ObjectValidators.ArticleNotePageValidator alias Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations alias Pleroma.Web.ActivityPub.ObjectValidators.QuestionOptionsValidator - alias Pleroma.Web.ActivityPub.Transmogrifier import Ecto.Changeset @@ -62,9 +61,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.QuestionValidator do defp fix(data) do data - |> CommonFixes.fix_actor() - |> CommonFixes.fix_object_defaults() - |> Transmogrifier.fix_emoji() + |> ArticleNotePageValidator.fix() |> fix_closed() end diff --git a/test/pleroma/web/activity_pub/transmogrifier/question_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/question_handling_test.exs index ae0314f26..e673ac4dc 100644 --- a/test/pleroma/web/activity_pub/transmogrifier/question_handling_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier/question_handling_test.exs @@ -103,6 +103,26 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.QuestionHandlingTest do assert Enum.sort(object.data["oneOf"]) == Enum.sort(options) end + test "GTS Question activity with a single, non-array tag" do + tag = %{ + "href" => "https://gts.example/tags/caturday", + "name" => "#caturday", + "type" => "Hashtag" + } + + data = + File.read!("test/fixtures/mastodon-question-activity.json") + |> Jason.decode!() + |> Kernel.put_in(["object", "tag"], tag) + + {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data) + object = Object.normalize(activity, fetch: false) + + [parsed_tag, tag_name] = Enum.sort(object.data["tag"]) + assert tag_name == "caturday" + assert parsed_tag == %{tag | "name" => tag_name} + end + test "Mastodon Question activity with custom emojis" do options = [ %{