2020-04-13 17:21:04 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2021-01-13 06:49:20 +00:00
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
2020-04-13 17:21:04 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.ApiSpec.CustomEmojiOperation do
|
|
|
|
alias OpenApiSpex.Operation
|
2020-04-24 10:46:59 +00:00
|
|
|
alias OpenApiSpex.Schema
|
2020-04-27 18:55:05 +00:00
|
|
|
alias Pleroma.Web.ApiSpec.Schemas.Emoji
|
2020-04-13 17:21:04 +00:00
|
|
|
|
|
|
|
def open_api_operation(action) do
|
|
|
|
operation = String.to_existing_atom("#{action}_operation")
|
|
|
|
apply(__MODULE__, operation, [])
|
|
|
|
end
|
|
|
|
|
|
|
|
def index_operation do
|
|
|
|
%Operation{
|
2021-02-03 12:38:59 +00:00
|
|
|
tags: ["Custom emojis"],
|
|
|
|
summary: "Retrieve a list of custom emojis",
|
2020-04-13 17:21:04 +00:00
|
|
|
description: "Returns custom emojis that are available on the server.",
|
|
|
|
operationId: "CustomEmojiController.index",
|
|
|
|
responses: %{
|
2020-04-27 18:55:05 +00:00
|
|
|
200 => Operation.response("Custom Emojis", "application/json", resposnse())
|
2020-04-13 17:21:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
2020-04-24 10:46:59 +00:00
|
|
|
|
2020-04-27 18:55:05 +00:00
|
|
|
defp resposnse do
|
2020-04-24 10:46:59 +00:00
|
|
|
%Schema{
|
|
|
|
title: "CustomEmojisResponse",
|
|
|
|
description: "Response schema for custom emojis",
|
|
|
|
type: :array,
|
2020-04-27 18:55:05 +00:00
|
|
|
items: custom_emoji(),
|
2020-04-24 10:46:59 +00:00
|
|
|
example: [
|
|
|
|
%{
|
|
|
|
"category" => "Fun",
|
|
|
|
"shortcode" => "blank",
|
|
|
|
"static_url" => "https://lain.com/emoji/blank.png",
|
|
|
|
"tags" => ["Fun"],
|
|
|
|
"url" => "https://lain.com/emoji/blank.png",
|
|
|
|
"visible_in_picker" => false
|
|
|
|
},
|
|
|
|
%{
|
|
|
|
"category" => "Gif,Fun",
|
|
|
|
"shortcode" => "firefox",
|
|
|
|
"static_url" => "https://lain.com/emoji/Firefox.gif",
|
|
|
|
"tags" => ["Gif", "Fun"],
|
|
|
|
"url" => "https://lain.com/emoji/Firefox.gif",
|
|
|
|
"visible_in_picker" => true
|
|
|
|
},
|
|
|
|
%{
|
|
|
|
"category" => "pack:mixed",
|
|
|
|
"shortcode" => "sadcat",
|
|
|
|
"static_url" => "https://lain.com/emoji/mixed/sadcat.png",
|
|
|
|
"tags" => ["pack:mixed"],
|
|
|
|
"url" => "https://lain.com/emoji/mixed/sadcat.png",
|
|
|
|
"visible_in_picker" => true
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
end
|
2020-04-27 18:55:05 +00:00
|
|
|
|
|
|
|
defp custom_emoji do
|
|
|
|
%Schema{
|
|
|
|
title: "CustomEmoji",
|
|
|
|
description: "Schema for a CustomEmoji",
|
|
|
|
allOf: [
|
|
|
|
Emoji,
|
|
|
|
%Schema{
|
|
|
|
type: :object,
|
|
|
|
properties: %{
|
|
|
|
category: %Schema{type: :string},
|
2020-09-18 21:50:00 +00:00
|
|
|
tags: %Schema{type: :array, items: %Schema{type: :string}}
|
2020-04-27 18:55:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
example: %{
|
|
|
|
"category" => "Fun",
|
|
|
|
"shortcode" => "aaaa",
|
|
|
|
"url" =>
|
|
|
|
"https://files.mastodon.social/custom_emojis/images/000/007/118/original/aaaa.png",
|
|
|
|
"static_url" =>
|
|
|
|
"https://files.mastodon.social/custom_emojis/images/000/007/118/static/aaaa.png",
|
|
|
|
"visible_in_picker" => true,
|
|
|
|
"tags" => ["Gif", "Fun"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
2020-04-13 17:21:04 +00:00
|
|
|
end
|