aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/api_spec
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2020-05-20 15:00:11 +0400
committerEgor Kislitsyn <egor@kislitsyn.com>2020-05-20 15:15:13 +0400
commitf3fc8b22b1dca8d432d066417e2bb9b62a3f1520 (patch)
tree6ba78a7555d1605951b530b0fdf57e5020b53714 /lib/pleroma/web/api_spec
parent9a5de0f4548cfe6b62265596bbe3cef2d639b978 (diff)
downloadpleroma-f3fc8b22b1dca8d432d066417e2bb9b62a3f1520.tar.gz
Move conversation actions to PleromaAPI.ConversationController
Diffstat (limited to 'lib/pleroma/web/api_spec')
-rw-r--r--lib/pleroma/web/api_spec/operations/pleroma_conversation_operation.ex106
-rw-r--r--lib/pleroma/web/api_spec/operations/pleroma_operation.ex93
2 files changed, 106 insertions, 93 deletions
diff --git a/lib/pleroma/web/api_spec/operations/pleroma_conversation_operation.ex b/lib/pleroma/web/api_spec/operations/pleroma_conversation_operation.ex
new file mode 100644
index 000000000..e885eab20
--- /dev/null
+++ b/lib/pleroma/web/api_spec/operations/pleroma_conversation_operation.ex
@@ -0,0 +1,106 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.ApiSpec.PleromaConversationOperation do
+ alias OpenApiSpex.Operation
+ alias OpenApiSpex.Schema
+ alias Pleroma.Web.ApiSpec.Schemas.Conversation
+ alias Pleroma.Web.ApiSpec.Schemas.FlakeID
+ alias Pleroma.Web.ApiSpec.StatusOperation
+
+ import Pleroma.Web.ApiSpec.Helpers
+
+ def open_api_operation(action) do
+ operation = String.to_existing_atom("#{action}_operation")
+ apply(__MODULE__, operation, [])
+ end
+
+ def show_operation do
+ %Operation{
+ tags: ["Conversations"],
+ summary: "The conversation with the given ID",
+ parameters: [
+ Operation.parameter(:id, :path, :string, "Conversation ID",
+ example: "123",
+ required: true
+ )
+ ],
+ security: [%{"oAuth" => ["read:statuses"]}],
+ operationId: "PleromaAPI.ConversationController.show",
+ responses: %{
+ 200 => Operation.response("Conversation", "application/json", Conversation)
+ }
+ }
+ end
+
+ def statuses_operation do
+ %Operation{
+ tags: ["Conversations"],
+ summary: "Timeline for a given conversation",
+ parameters: [
+ Operation.parameter(:id, :path, :string, "Conversation ID",
+ example: "123",
+ required: true
+ )
+ | pagination_params()
+ ],
+ security: [%{"oAuth" => ["read:statuses"]}],
+ operationId: "PleromaAPI.ConversationController.statuses",
+ responses: %{
+ 200 =>
+ Operation.response(
+ "Array of Statuses",
+ "application/json",
+ StatusOperation.array_of_statuses()
+ )
+ }
+ }
+ end
+
+ def update_operation do
+ %Operation{
+ tags: ["Conversations"],
+ summary: "Update a conversation. Used to change the set of recipients.",
+ parameters: [
+ Operation.parameter(:id, :path, :string, "Conversation ID",
+ example: "123",
+ required: true
+ ),
+ Operation.parameter(
+ :recipients,
+ :query,
+ %Schema{type: :array, items: FlakeID},
+ "A list of ids of users that should receive posts to this conversation. This will replace the current list of recipients, so submit the full list. The owner of owner of the conversation will always be part of the set of recipients, though.",
+ required: true
+ )
+ ],
+ security: [%{"oAuth" => ["write:conversations"]}],
+ operationId: "PleromaAPI.ConversationController.update",
+ responses: %{
+ 200 => Operation.response("Conversation", "application/json", Conversation)
+ }
+ }
+ end
+
+ def mark_as_read_operation do
+ %Operation{
+ tags: ["Conversations"],
+ summary: "Marks all user's conversations as read",
+ security: [%{"oAuth" => ["write:conversations"]}],
+ operationId: "PleromaAPI.ConversationController.mark_as_read",
+ responses: %{
+ 200 =>
+ Operation.response(
+ "Array of Conversations that were marked as read",
+ "application/json",
+ %Schema{
+ type: :array,
+ items: Conversation,
+ example: [Conversation.schema().example]
+ }
+ )
+ }
+ }
+ end
+end
diff --git a/lib/pleroma/web/api_spec/operations/pleroma_operation.ex b/lib/pleroma/web/api_spec/operations/pleroma_operation.ex
index 7e46ba553..d28451933 100644
--- a/lib/pleroma/web/api_spec/operations/pleroma_operation.ex
+++ b/lib/pleroma/web/api_spec/operations/pleroma_operation.ex
@@ -7,105 +7,12 @@ defmodule Pleroma.Web.ApiSpec.PleromaOperation do
alias OpenApiSpex.Schema
alias Pleroma.Web.ApiSpec.NotificationOperation
alias Pleroma.Web.ApiSpec.Schemas.ApiError
- alias Pleroma.Web.ApiSpec.Schemas.Conversation
- alias Pleroma.Web.ApiSpec.Schemas.FlakeID
- alias Pleroma.Web.ApiSpec.StatusOperation
-
- import Pleroma.Web.ApiSpec.Helpers
def open_api_operation(action) do
operation = String.to_existing_atom("#{action}_operation")
apply(__MODULE__, operation, [])
end
- def conversation_operation do
- %Operation{
- tags: ["Conversations"],
- summary: "The conversation with the given ID",
- parameters: [
- Operation.parameter(:id, :path, :string, "Conversation ID",
- example: "123",
- required: true
- )
- ],
- security: [%{"oAuth" => ["read:statuses"]}],
- operationId: "PleromaController.conversation",
- responses: %{
- 200 => Operation.response("Conversation", "application/json", Conversation)
- }
- }
- end
-
- def conversation_statuses_operation do
- %Operation{
- tags: ["Conversations"],
- summary: "Timeline for a given conversation",
- parameters: [
- Operation.parameter(:id, :path, :string, "Conversation ID",
- example: "123",
- required: true
- )
- | pagination_params()
- ],
- security: [%{"oAuth" => ["read:statuses"]}],
- operationId: "PleromaController.conversation_statuses",
- responses: %{
- 200 =>
- Operation.response(
- "Array of Statuses",
- "application/json",
- StatusOperation.array_of_statuses()
- )
- }
- }
- end
-
- def update_conversation_operation do
- %Operation{
- tags: ["Conversations"],
- summary: "Update a conversation. Used to change the set of recipients.",
- parameters: [
- Operation.parameter(:id, :path, :string, "Conversation ID",
- example: "123",
- required: true
- ),
- Operation.parameter(
- :recipients,
- :query,
- %Schema{type: :array, items: FlakeID},
- "A list of ids of users that should receive posts to this conversation. This will replace the current list of recipients, so submit the full list. The owner of owner of the conversation will always be part of the set of recipients, though.",
- required: true
- )
- ],
- security: [%{"oAuth" => ["write:conversations"]}],
- operationId: "PleromaController.update_conversation",
- responses: %{
- 200 => Operation.response("Conversation", "application/json", Conversation)
- }
- }
- end
-
- def mark_conversations_as_read_operation do
- %Operation{
- tags: ["Conversations"],
- summary: "Marks all user's conversations as read",
- security: [%{"oAuth" => ["write:conversations"]}],
- operationId: "PleromaController.mark_conversations_as_read",
- responses: %{
- 200 =>
- Operation.response(
- "Array of Conversations that were marked as read",
- "application/json",
- %Schema{
- type: :array,
- items: Conversation,
- example: [Conversation.schema().example]
- }
- )
- }
- }
- end
-
def mark_notifications_as_read_operation do
%Operation{
tags: ["Notifications"],