1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 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",
32 "Include reactions from muted acccounts."
35 security: [%{"oAuth" => ["read:statuses"]}],
36 operationId: "EmojiReactionController.index",
38 200 => array_of_reactions_response()
43 def create_operation do
45 tags: ["Emoji Reactions"],
46 summary: "React to a post with a unicode emoji",
48 Operation.parameter(:id, :path, FlakeID, "Status ID", required: true),
49 Operation.parameter(:emoji, :path, :string, "A single character unicode emoji",
53 security: [%{"oAuth" => ["write:statuses"]}],
54 operationId: "EmojiReactionController.create",
56 200 => Operation.response("Status", "application/json", Status),
57 400 => Operation.response("Bad Request", "application/json", ApiError)
62 def delete_operation do
64 tags: ["Emoji Reactions"],
65 summary: "Remove a reaction to a post with a unicode emoji",
67 Operation.parameter(:id, :path, FlakeID, "Status ID", required: true),
68 Operation.parameter(:emoji, :path, :string, "A single character unicode emoji",
72 security: [%{"oAuth" => ["write:statuses"]}],
73 operationId: "EmojiReactionController.delete",
75 200 => Operation.response("Status", "application/json", Status)
80 defp array_of_reactions_response do
81 Operation.response("Array of Emoji Reactions", "application/json", %Schema{
83 items: emoji_reaction(),
84 example: [emoji_reaction().example]
88 defp emoji_reaction do
90 title: "EmojiReaction",
93 name: %Schema{type: :string, description: "Emoji"},
94 count: %Schema{type: :integer, description: "Count of reactions with this emoji"},
95 me: %Schema{type: :boolean, description: "Did I react with this emoji?"},
99 description: "Array of accounts reacted with this emoji"
106 "accounts" => [Account.schema().example]