Remerge of hashtag following (#341)
[akkoma] / lib / pleroma / web / api_spec / schemas / poll.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ApiSpec.Schemas.Poll do
6 alias OpenApiSpex.Schema
7 alias Pleroma.Web.ApiSpec.Schemas.Emoji
8 alias Pleroma.Web.ApiSpec.Schemas.FlakeID
9
10 require OpenApiSpex
11
12 OpenApiSpex.schema(%{
13 title: "Poll",
14 description: "Represents a poll attached to a status",
15 type: :object,
16 properties: %{
17 id: FlakeID,
18 expires_at: %Schema{
19 type: :string,
20 format: :"date-time",
21 nullable: true,
22 description: "When the poll ends"
23 },
24 expired: %Schema{type: :boolean, description: "Is the poll currently expired?"},
25 multiple: %Schema{
26 type: :boolean,
27 description: "Does the poll allow multiple-choice answers?"
28 },
29 votes_count: %Schema{
30 type: :integer,
31 description: "How many votes have been received. Number."
32 },
33 voters_count: %Schema{
34 type: :integer,
35 description: "How many unique accounts have voted. Number."
36 },
37 voted: %Schema{
38 type: :boolean,
39 nullable: true,
40 description:
41 "When called with a user token, has the authorized user voted? Boolean, or null if no current user."
42 },
43 emojis: %Schema{
44 type: :array,
45 items: Emoji,
46 description: "Custom emoji to be used for rendering poll options."
47 },
48 options: %Schema{
49 type: :array,
50 items: %Schema{
51 title: "PollOption",
52 type: :object,
53 properties: %{
54 title: %Schema{type: :string},
55 votes_count: %Schema{type: :integer}
56 }
57 },
58 description: "Possible answers for the poll."
59 }
60 },
61 example: %{
62 id: "34830",
63 expires_at: "2019-12-05T04:05:08.302Z",
64 expired: true,
65 multiple: false,
66 votes_count: 10,
67 voters_count: 10,
68 voted: true,
69 own_votes: [
70 1
71 ],
72 options: [
73 %{
74 title: "accept",
75 votes_count: 6
76 },
77 %{
78 title: "deny",
79 votes_count: 4
80 }
81 ],
82 emojis: []
83 }
84 })
85 end