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.PleromaOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.NotificationOperation
9 alias Pleroma.Web.ApiSpec.Schemas.ApiError
10 alias Pleroma.Web.ApiSpec.Schemas.Conversation
11 alias Pleroma.Web.ApiSpec.Schemas.FlakeID
12 alias Pleroma.Web.ApiSpec.StatusOperation
14 import Pleroma.Web.ApiSpec.Helpers
16 def open_api_operation(action) do
17 operation = String.to_existing_atom("#{action}_operation")
18 apply(__MODULE__, operation, [])
21 def conversation_operation do
23 tags: ["Conversations"],
24 summary: "The conversation with the given ID",
26 Operation.parameter(:id, :path, :string, "Conversation ID",
31 security: [%{"oAuth" => ["read:statuses"]}],
32 operationId: "PleromaController.conversation",
34 200 => Operation.response("Conversation", "application/json", Conversation)
39 def conversation_statuses_operation do
41 tags: ["Conversations"],
42 summary: "Timeline for a given conversation",
44 Operation.parameter(:id, :path, :string, "Conversation ID",
50 security: [%{"oAuth" => ["read:statuses"]}],
51 operationId: "PleromaController.conversation_statuses",
57 StatusOperation.array_of_statuses()
63 def update_conversation_operation do
65 tags: ["Conversations"],
66 summary: "Update a conversation. Used to change the set of recipients.",
68 Operation.parameter(:id, :path, :string, "Conversation ID",
75 %Schema{type: :array, items: FlakeID},
76 "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.",
80 security: [%{"oAuth" => ["write:conversations"]}],
81 operationId: "PleromaController.update_conversation",
83 200 => Operation.response("Conversation", "application/json", Conversation)
88 def mark_conversations_as_read_operation do
90 tags: ["Conversations"],
91 summary: "Marks all user's conversations as read",
92 security: [%{"oAuth" => ["write:conversations"]}],
93 operationId: "PleromaController.mark_conversations_as_read",
97 "Array of Conversations that were marked as read",
102 example: [Conversation.schema().example]
109 def mark_notifications_as_read_operation do
111 tags: ["Notifications"],
112 summary: "Mark notifications as read. Query parameters are mutually exclusive.",
114 Operation.parameter(:id, :query, :string, "A single notification ID to read"),
115 Operation.parameter(:max_id, :query, :string, "Read all notifications up to this id")
117 security: [%{"oAuth" => ["write:notifications"]}],
118 operationId: "PleromaController.mark_notifications_as_read",
122 "A Notification or array of Motifications",
126 %Schema{type: :array, items: NotificationOperation.notification()},
127 NotificationOperation.notification()
131 400 => Operation.response("Bad Request", "application/json", ApiError)