X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Fapi_spec%2Foperations%2Femoji_reaction_operation.ex;h=b254fc57bd6ac07a1093be7dd20e0814453dd6e3;hb=07a48b9293e4046c50b5d424d60a1bf16c7cc198;hp=7c08fbaa70cf1ee101e52177da42c29cd9952793;hpb=a57e7f3503c485de64c4e001529a6e06a1a35b25;p=akkoma diff --git a/lib/pleroma/web/api_spec/operations/emoji_reaction_operation.ex b/lib/pleroma/web/api_spec/operations/emoji_reaction_operation.ex index 7c08fbaa7..b254fc57b 100644 --- a/lib/pleroma/web/api_spec/operations/emoji_reaction_operation.ex +++ b/lib/pleroma/web/api_spec/operations/emoji_reaction_operation.ex @@ -1,11 +1,12 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2020 Pleroma Authors +# Copyright © 2017-2021 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.ApiSpec.EmojiReactionOperation do alias OpenApiSpex.Operation alias OpenApiSpex.Schema alias Pleroma.Web.ApiSpec.Schemas.Account + alias Pleroma.Web.ApiSpec.Schemas.ApiError alias Pleroma.Web.ApiSpec.Schemas.FlakeID alias Pleroma.Web.ApiSpec.Schemas.Status @@ -16,13 +17,19 @@ defmodule Pleroma.Web.ApiSpec.EmojiReactionOperation do def index_operation do %Operation{ - tags: ["Emoji Reactions"], + tags: ["Emoji reactions"], summary: "Get an object of emoji to account mappings with accounts that reacted to the post", parameters: [ Operation.parameter(:id, :path, FlakeID, "Status ID", required: true), Operation.parameter(:emoji, :path, :string, "Filter by a single unicode emoji", - required: false + required: nil + ), + Operation.parameter( + :with_muted, + :query, + :boolean, + "Include reactions from muted acccounts." ) ], security: [%{"oAuth" => ["read:statuses"]}], @@ -35,29 +42,38 @@ defmodule Pleroma.Web.ApiSpec.EmojiReactionOperation do def create_operation do %Operation{ - tags: ["Emoji Reactions"], - summary: "React to a post with a unicode emoji", + tags: ["Emoji reactions"], + summary: "React to a post with either a unicode or custom emoji", parameters: [ Operation.parameter(:id, :path, FlakeID, "Status ID", required: true), - Operation.parameter(:emoji, :path, :string, "A single character unicode emoji", + Operation.parameter( + :emoji, + :path, + :string, + "A single character unicode emoji, or a \:shortcode\: format emoji name", required: true ) ], security: [%{"oAuth" => ["write:statuses"]}], operationId: "EmojiReactionController.create", responses: %{ - 200 => Operation.response("Status", "application/json", Status) + 200 => Operation.response("Status", "application/json", Status), + 400 => Operation.response("Bad Request", "application/json", ApiError) } } end def delete_operation do %Operation{ - tags: ["Emoji Reactions"], - summary: "Remove a reaction to a post with a unicode emoji", + tags: ["Emoji reactions"], + summary: "Remove a reaction to a post with either a unicode or custom emoji", parameters: [ Operation.parameter(:id, :path, FlakeID, "Status ID", required: true), - Operation.parameter(:emoji, :path, :string, "A single character unicode emoji", + Operation.parameter( + :emoji, + :path, + :string, + "A single character unicode emoji, or a \:shortcode\: format emoji name", required: true ) ], @@ -70,10 +86,10 @@ defmodule Pleroma.Web.ApiSpec.EmojiReactionOperation do end defp array_of_reactions_response do - Operation.response("Array of Emoji Reactions", "application/json", %Schema{ + Operation.response("Array of Emoji reactions", "application/json", %Schema{ type: :array, items: emoji_reaction(), - example: [emoji_reaction().example] + example: emoji_reaction().example }) end @@ -85,18 +101,34 @@ defmodule Pleroma.Web.ApiSpec.EmojiReactionOperation do name: %Schema{type: :string, description: "Emoji"}, count: %Schema{type: :integer, description: "Count of reactions with this emoji"}, me: %Schema{type: :boolean, description: "Did I react with this emoji?"}, + url: %Schema{ + type: :string, + description: "URL of the emoji if it's custom - otherwise null", + nullable: true, + format: "url" + }, accounts: %Schema{ type: :array, items: Account, description: "Array of accounts reacted with this emoji" } }, - example: %{ - "name" => "😱", - "count" => 1, - "me" => false, - "accounts" => [Account.schema().example] - } + example: [ + %{ + "name" => "😱", + "count" => 1, + "me" => false, + "url" => nil, + "accounts" => [Account.schema().example] + }, + %{ + "name" => "dinosaur", + "count" => 1, + "me" => false, + "url" => "https://akkoma.dev/emoji/dinosaur.png", + "accounts" => [Account.schema().example] + } + ] } end end