logo

pleroma

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

custom_emoji_operation.ex (2659B)


  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.CustomEmojiOperation do
  5. alias OpenApiSpex.Operation
  6. alias OpenApiSpex.Schema
  7. alias Pleroma.Web.ApiSpec.Schemas.Emoji
  8. def open_api_operation(action) do
  9. operation = String.to_existing_atom("#{action}_operation")
  10. apply(__MODULE__, operation, [])
  11. end
  12. def index_operation do
  13. %Operation{
  14. tags: ["Custom emojis"],
  15. summary: "Retrieve a list of custom emojis",
  16. description: "Returns custom emojis that are available on the server.",
  17. operationId: "CustomEmojiController.index",
  18. responses: %{
  19. 200 => Operation.response("Custom Emojis", "application/json", resposnse())
  20. }
  21. }
  22. end
  23. defp resposnse do
  24. %Schema{
  25. title: "CustomEmojisResponse",
  26. description: "Response schema for custom emojis",
  27. type: :array,
  28. items: custom_emoji(),
  29. example: [
  30. %{
  31. "category" => "Fun",
  32. "shortcode" => "blank",
  33. "static_url" => "https://lain.com/emoji/blank.png",
  34. "tags" => ["Fun"],
  35. "url" => "https://lain.com/emoji/blank.png",
  36. "visible_in_picker" => false
  37. },
  38. %{
  39. "category" => "Gif,Fun",
  40. "shortcode" => "firefox",
  41. "static_url" => "https://lain.com/emoji/Firefox.gif",
  42. "tags" => ["Gif", "Fun"],
  43. "url" => "https://lain.com/emoji/Firefox.gif",
  44. "visible_in_picker" => true
  45. },
  46. %{
  47. "category" => "pack:mixed",
  48. "shortcode" => "sadcat",
  49. "static_url" => "https://lain.com/emoji/mixed/sadcat.png",
  50. "tags" => ["pack:mixed"],
  51. "url" => "https://lain.com/emoji/mixed/sadcat.png",
  52. "visible_in_picker" => true
  53. }
  54. ]
  55. }
  56. end
  57. defp custom_emoji do
  58. %Schema{
  59. title: "CustomEmoji",
  60. description: "Schema for a CustomEmoji",
  61. allOf: [
  62. Emoji,
  63. %Schema{
  64. type: :object,
  65. properties: %{
  66. category: %Schema{type: :string},
  67. tags: %Schema{type: :array, items: %Schema{type: :string}}
  68. }
  69. }
  70. ],
  71. example: %{
  72. "category" => "Fun",
  73. "shortcode" => "aaaa",
  74. "url" =>
  75. "https://files.mastodon.social/custom_emojis/images/000/007/118/original/aaaa.png",
  76. "static_url" =>
  77. "https://files.mastodon.social/custom_emojis/images/000/007/118/static/aaaa.png",
  78. "visible_in_picker" => true,
  79. "tags" => ["Gif", "Fun"]
  80. }
  81. }
  82. end
  83. end