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.PleromaConversationOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Schemas.Conversation
9 alias Pleroma.Web.ApiSpec.Schemas.FlakeID
10 alias Pleroma.Web.ApiSpec.StatusOperation
12 import Pleroma.Web.ApiSpec.Helpers
14 def open_api_operation(action) do
15 operation = String.to_existing_atom("#{action}_operation")
16 apply(__MODULE__, operation, [])
21 tags: ["Conversations"],
22 summary: "The conversation with the given ID",
24 Operation.parameter(:id, :path, :string, "Conversation ID",
29 security: [%{"oAuth" => ["read:statuses"]}],
30 operationId: "PleromaAPI.ConversationController.show",
32 200 => Operation.response("Conversation", "application/json", Conversation)
37 def statuses_operation do
39 tags: ["Conversations"],
40 summary: "Timeline for a given conversation",
42 Operation.parameter(:id, :path, :string, "Conversation ID",
48 security: [%{"oAuth" => ["read:statuses"]}],
49 operationId: "PleromaAPI.ConversationController.statuses",
55 StatusOperation.array_of_statuses()
61 def update_operation do
63 tags: ["Conversations"],
64 summary: "Update a conversation. Used to change the set of recipients.",
66 Operation.parameter(:id, :path, :string, "Conversation ID",
73 %Schema{type: :array, items: FlakeID},
74 "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.",
78 security: [%{"oAuth" => ["write:conversations"]}],
79 operationId: "PleromaAPI.ConversationController.update",
81 200 => Operation.response("Conversation", "application/json", Conversation)
86 def mark_as_read_operation do
88 tags: ["Conversations"],
89 summary: "Marks all user's conversations as read",
90 security: [%{"oAuth" => ["write:conversations"]}],
91 operationId: "PleromaAPI.ConversationController.mark_as_read",
95 "Array of Conversations that were marked as read",
100 example: [Conversation.schema().example]