Expose nonAnonymous field from Smithereen polls

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-08-07 23:56:52 +02:00
parent e3ea311cd5
commit 93370b870a
3 changed files with 15 additions and 2 deletions

View file

@ -29,6 +29,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.QuestionValidator do
field(:closed, ObjectValidators.DateTime) field(:closed, ObjectValidators.DateTime)
field(:voters, {:array, ObjectValidators.ObjectID}, default: []) field(:voters, {:array, ObjectValidators.ObjectID}, default: [])
field(:nonAnonymous, :boolean)
embeds_many(:anyOf, QuestionOptionsValidator) embeds_many(:anyOf, QuestionOptionsValidator)
embeds_many(:oneOf, QuestionOptionsValidator) embeds_many(:oneOf, QuestionOptionsValidator)
end end

View file

@ -56,6 +56,12 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Poll do
} }
}, },
description: "Possible answers for the poll." description: "Possible answers for the poll."
},
pleroma: %Schema{
type: :object,
properties: %{
non_anonymous: %Schema{type: :boolean, description: "Is the voters collection public?"}
}
} }
}, },
example: %{ example: %{
@ -79,7 +85,10 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Poll do
votes_count: 4 votes_count: 4
} }
], ],
emojis: [] emojis: [],
pleroma: %{
non_anonymous: false
}
} }
}) })
end end

View file

@ -21,7 +21,10 @@ defmodule Pleroma.Web.MastodonAPI.PollView do
votes_count: votes_count, votes_count: votes_count,
voters_count: voters_count(object), voters_count: voters_count(object),
options: options, options: options,
emojis: Pleroma.Web.MastodonAPI.StatusView.build_emojis(object.data["emoji"]) emojis: Pleroma.Web.MastodonAPI.StatusView.build_emojis(object.data["emoji"]),
pleroma: %{
non_anonymous: object.data["nonAnonymous"] || false
}
} }
if params[:for] do if params[:for] do