logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

poll.ex (2255B)


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