From 4de58c2b2c598788c6c1c069741e536f3b215d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Thu, 18 Aug 2022 06:38:03 +0000 Subject: [PATCH] Revert "Merge branch 'polls' into 'develop'" This reverts merge request !152 --- lib/pleroma/constants.ex | 3 +-- .../object_validators/question_validator.ex | 1 - .../web/activity_pub/transmogrifier.ex | 7 ------- .../web/mastodon_api/views/poll_view.ex | 4 ---- priv/static/schemas/litepub-0.1.jsonld | 3 +-- .../transmogrifier/question_handling_test.exs | 19 ------------------- .../web/mastodon_api/views/poll_view_test.exs | 9 +-------- 7 files changed, 3 insertions(+), 43 deletions(-) diff --git a/lib/pleroma/constants.ex b/lib/pleroma/constants.ex index e59b85ea3e..4d69b840cb 100644 --- a/lib/pleroma/constants.ex +++ b/lib/pleroma/constants.ex @@ -22,8 +22,7 @@ defmodule Pleroma.Constants do "generator", "assigned_account", "rules", - "content_type", - "voters" + "content_type" ] ) 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 00b85a2148..4bfa295084 100644 --- a/lib/pleroma/web/activity_pub/object_validators/question_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validators/question_validator.ex @@ -29,7 +29,6 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.QuestionValidator do field(:closed, ObjectValidators.DateTime) field(:voters, {:array, ObjectValidators.ObjectID}, default: []) - field(:votersCount, :integer) field(:nonAnonymous, :boolean) embeds_many(:anyOf, QuestionOptionsValidator) embeds_many(:oneOf, QuestionOptionsValidator) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 214a6b587e..816823b1c1 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -723,12 +723,6 @@ def replies(%{"replies" => %{"items" => items}}) when not is_nil(items) do def replies(_), do: [] - defp set_voters_count(%{"voters" => [_ | _] = voters} = obj) do - Map.merge(obj, %{"votersCount" => length(voters)}) - end - - defp set_voters_count(obj), do: obj - # Prepares the object of an outgoing create activity. def prepare_object(object) do object @@ -741,7 +735,6 @@ def prepare_object(object) do |> set_reply_to_uri |> set_quote_url |> set_replies - |> set_voters_count |> strip_internal_fields |> strip_internal_tags |> set_type diff --git a/lib/pleroma/web/mastodon_api/views/poll_view.ex b/lib/pleroma/web/mastodon_api/views/poll_view.ex index 5bc482c8d8..1e3c9f36d4 100644 --- a/lib/pleroma/web/mastodon_api/views/poll_view.ex +++ b/lib/pleroma/web/mastodon_api/views/poll_view.ex @@ -71,10 +71,6 @@ defp options_and_votes_count(options) do end) end - defp voters_count(%{data: %{"votersCount" => voters}}) when is_number(voters) do - voters - end - defp voters_count(%{data: %{"voters" => [_ | _] = voters}}) do length(voters) end diff --git a/priv/static/schemas/litepub-0.1.jsonld b/priv/static/schemas/litepub-0.1.jsonld index 970ceabdcf..d47f55c692 100644 --- a/priv/static/schemas/litepub-0.1.jsonld +++ b/priv/static/schemas/litepub-0.1.jsonld @@ -41,8 +41,7 @@ }, "vcard": "http://www.w3.org/2006/vcard/ns#", "sm": "http://smithereen.software/ns#", - "nonAnonymous": "sm:nonAnonymous", - "votersCount" : "toot:votersCount" + "nonAnonymous": "sm:nonAnonymous" } ] } 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 66f8499faf..d22ec400dc 100644 --- a/test/pleroma/web/activity_pub/transmogrifier/question_handling_test.exs +++ b/test/pleroma/web/activity_pub/transmogrifier/question_handling_test.exs @@ -173,23 +173,4 @@ test "accepts a Question with no content" do assert {:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(data) end - - test "it strips voters list and displays voters count instead" do - user = insert(:user) - other_user = insert(:user) - - {:ok, activity} = - CommonAPI.post(user, %{ - status: "???", - poll: %{expires_in: 10, options: ["yes", "no"]} - }) - - object = Object.normalize(activity, fetch: false) - {:ok, _, _} = CommonAPI.vote(other_user, object, [1]) - - {:ok, modified} = Transmogrifier.prepare_outgoing(activity.data) - - refute Map.has_key?(modified["object"], "voters") - assert modified["object"]["votersCount"] == 1 - end end diff --git a/test/pleroma/web/mastodon_api/views/poll_view_test.exs b/test/pleroma/web/mastodon_api/views/poll_view_test.exs index 98f1f365fc..3aa73c224e 100644 --- a/test/pleroma/web/mastodon_api/views/poll_view_test.exs +++ b/test/pleroma/web/mastodon_api/views/poll_view_test.exs @@ -167,14 +167,7 @@ test "doesn't strips HTML tags" do } = PollView.render("show.json", %{object: object}) end - test "displays correct voters count" do - object = Object.normalize("https://friends.grishka.me/posts/54642", fetch: true) - result = PollView.render("show.json", %{object: object}) - - assert result[:voters_count] == 14 - end - - test "detects that poll is non anonymous" do + test "that poll is non anonymous" do object = Object.normalize("https://friends.grishka.me/posts/54642", fetch: true) result = PollView.render("show.json", %{object: object})