Merge branch 'revert-f6e02270' into 'develop'
Revert "Merge branch 'polls' into 'develop'" See merge request soapbox-pub/soapbox-be!164
This commit is contained in:
commit
5b8ad6bc91
7 changed files with 3 additions and 43 deletions
|
@ -22,8 +22,7 @@ defmodule Pleroma.Constants do
|
|||
"generator",
|
||||
"assigned_account",
|
||||
"rules",
|
||||
"content_type",
|
||||
"voters"
|
||||
"content_type"
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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})
|
||||
|
||||
|
|
Loading…
Reference in a new issue