2020-04-08 18:33:25 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.ApiSpec.Schemas.Poll do
|
|
|
|
alias OpenApiSpex.Schema
|
2020-04-27 18:55:05 +00:00
|
|
|
alias Pleroma.Web.ApiSpec.Schemas.Emoji
|
2020-04-21 19:54:45 +00:00
|
|
|
alias Pleroma.Web.ApiSpec.Schemas.FlakeID
|
2020-04-08 18:33:25 +00:00
|
|
|
|
|
|
|
require OpenApiSpex
|
|
|
|
|
|
|
|
OpenApiSpex.schema(%{
|
|
|
|
title: "Poll",
|
2020-05-05 16:14:22 +00:00
|
|
|
description: "Represents a poll attached to a status",
|
2020-04-08 18:33:25 +00:00
|
|
|
type: :object,
|
|
|
|
properties: %{
|
2020-04-21 19:54:45 +00:00
|
|
|
id: FlakeID,
|
2020-05-05 16:14:22 +00:00
|
|
|
expires_at: %Schema{
|
|
|
|
type: :string,
|
|
|
|
format: :"date-time",
|
|
|
|
nullable: true,
|
|
|
|
description: "When the poll ends"
|
|
|
|
},
|
|
|
|
expired: %Schema{type: :boolean, description: "Is the poll currently expired?"},
|
|
|
|
multiple: %Schema{
|
|
|
|
type: :boolean,
|
|
|
|
description: "Does the poll allow multiple-choice answers?"
|
|
|
|
},
|
|
|
|
votes_count: %Schema{
|
|
|
|
type: :integer,
|
2020-11-04 09:20:09 +00:00
|
|
|
description: "How many votes have been received. Number."
|
|
|
|
},
|
|
|
|
voters_count: %Schema{
|
|
|
|
type: :integer,
|
|
|
|
description: "How many unique accounts have voted. Number."
|
2020-05-05 16:14:22 +00:00
|
|
|
},
|
|
|
|
voted: %Schema{
|
|
|
|
type: :boolean,
|
|
|
|
nullable: true,
|
|
|
|
description:
|
|
|
|
"When called with a user token, has the authorized user voted? Boolean, or null if no current user."
|
|
|
|
},
|
|
|
|
emojis: %Schema{
|
|
|
|
type: :array,
|
|
|
|
items: Emoji,
|
|
|
|
description: "Custom emoji to be used for rendering poll options."
|
|
|
|
},
|
2020-04-08 18:33:25 +00:00
|
|
|
options: %Schema{
|
|
|
|
type: :array,
|
|
|
|
items: %Schema{
|
2020-05-05 16:14:22 +00:00
|
|
|
title: "PollOption",
|
2020-04-08 18:33:25 +00:00
|
|
|
type: :object,
|
|
|
|
properties: %{
|
|
|
|
title: %Schema{type: :string},
|
|
|
|
votes_count: %Schema{type: :integer}
|
|
|
|
}
|
2020-05-05 16:14:22 +00:00
|
|
|
},
|
|
|
|
description: "Possible answers for the poll."
|
2020-04-08 18:33:25 +00:00
|
|
|
}
|
2020-05-05 16:14:22 +00:00
|
|
|
},
|
|
|
|
example: %{
|
|
|
|
id: "34830",
|
|
|
|
expires_at: "2019-12-05T04:05:08.302Z",
|
|
|
|
expired: true,
|
|
|
|
multiple: false,
|
|
|
|
votes_count: 10,
|
2020-11-04 09:20:09 +00:00
|
|
|
voters_count: 10,
|
2020-05-05 16:14:22 +00:00
|
|
|
voted: true,
|
|
|
|
own_votes: [
|
|
|
|
1
|
|
|
|
],
|
|
|
|
options: [
|
|
|
|
%{
|
|
|
|
title: "accept",
|
|
|
|
votes_count: 6
|
|
|
|
},
|
|
|
|
%{
|
|
|
|
title: "deny",
|
|
|
|
votes_count: 4
|
|
|
|
}
|
|
|
|
],
|
|
|
|
emojis: []
|
2020-04-08 18:33:25 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
end
|