1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ApiSpec.EmojiReactionOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Schemas.Account
9 alias Pleroma.Web.ApiSpec.Schemas.FlakeID
10 alias Pleroma.Web.ApiSpec.Schemas.Status
12 def open_api_operation(action) do
13 operation = String.to_existing_atom("#{action}_operation")
14 apply(__MODULE__, operation, [])
17 def index_operation do
19 tags: ["Emoji Reactions"],
21 "Get an object of emoji to account mappings with accounts that reacted to the post",
23 Operation.parameter(:id, :path, FlakeID, "Status ID", required: true),
24 Operation.parameter(:emoji, :path, :string, "Filter by a single unicode emoji",
28 security: [%{"oAuth" => ["read:statuses"]}],
29 operationId: "EmojiReactionController.index",
31 200 => array_of_reactions_response()
36 def create_operation do
38 tags: ["Emoji Reactions"],
39 summary: "React to a post with a unicode emoji",
41 Operation.parameter(:id, :path, FlakeID, "Status ID", required: true),
42 Operation.parameter(:emoji, :path, :string, "A single character unicode emoji",
46 security: [%{"oAuth" => ["write:statuses"]}],
47 operationId: "EmojiReactionController.create",
49 200 => Operation.response("Status", "application/json", Status)
54 def delete_operation do
56 tags: ["Emoji Reactions"],
57 summary: "Remove a reaction to a post with a unicode emoji",
59 Operation.parameter(:id, :path, FlakeID, "Status ID", required: true),
60 Operation.parameter(:emoji, :path, :string, "A single character unicode emoji",
64 security: [%{"oAuth" => ["write:statuses"]}],
65 operationId: "EmojiReactionController.delete",
67 200 => Operation.response("Status", "application/json", Status)
72 defp array_of_reactions_response do
73 Operation.response("Array of Emoji Reactions", "application/json", %Schema{
75 items: emoji_reaction(),
76 example: [emoji_reaction().example]
80 defp emoji_reaction do
82 title: "EmojiReaction",
85 name: %Schema{type: :string, description: "Emoji"},
86 count: %Schema{type: :integer, description: "Count of reactions with this emoji"},
87 me: %Schema{type: :boolean, description: "Did I react with this emoji?"},
91 description: "Array of accounts reacted with this emoji"
98 "accounts" => [Account.schema().example]