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.ApiError
10 alias Pleroma.Web.ApiSpec.Schemas.FlakeID
11 alias Pleroma.Web.ApiSpec.Schemas.Status
13 def open_api_operation(action) do
14 operation = String.to_existing_atom("#{action}_operation")
15 apply(__MODULE__, operation, [])
18 def index_operation do
20 tags: ["Emoji Reactions"],
22 "Get an object of emoji to account mappings with accounts that reacted to the post",
24 Operation.parameter(:id, :path, FlakeID, "Status ID", required: true),
25 Operation.parameter(:emoji, :path, :string, "Filter by a single unicode emoji",
29 security: [%{"oAuth" => ["read:statuses"]}],
30 operationId: "EmojiReactionController.index",
32 200 => array_of_reactions_response()
37 def create_operation do
39 tags: ["Emoji Reactions"],
40 summary: "React to a post with a unicode emoji",
42 Operation.parameter(:id, :path, FlakeID, "Status ID", required: true),
43 Operation.parameter(:emoji, :path, :string, "A single character unicode emoji",
47 security: [%{"oAuth" => ["write:statuses"]}],
48 operationId: "EmojiReactionController.create",
50 200 => Operation.response("Status", "application/json", Status),
51 400 => Operation.response("Bad Request", "application/json", ApiError)
56 def delete_operation do
58 tags: ["Emoji Reactions"],
59 summary: "Remove a reaction to a post with a unicode emoji",
61 Operation.parameter(:id, :path, FlakeID, "Status ID", required: true),
62 Operation.parameter(:emoji, :path, :string, "A single character unicode emoji",
66 security: [%{"oAuth" => ["write:statuses"]}],
67 operationId: "EmojiReactionController.delete",
69 200 => Operation.response("Status", "application/json", Status)
74 defp array_of_reactions_response do
75 Operation.response("Array of Emoji Reactions", "application/json", %Schema{
77 items: emoji_reaction(),
78 example: [emoji_reaction().example]
82 defp emoji_reaction do
84 title: "EmojiReaction",
87 name: %Schema{type: :string, description: "Emoji"},
88 count: %Schema{type: :integer, description: "Count of reactions with this emoji"},
89 me: %Schema{type: :boolean, description: "Did I react with this emoji?"},
93 description: "Array of accounts reacted with this emoji"
100 "accounts" => [Account.schema().example]