add remote user count for the heck of it
[akkoma] / lib / pleroma / web / api_spec / operations / conversation_operation.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ApiSpec.ConversationOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Schemas.Conversation
9 alias Pleroma.Web.ApiSpec.Schemas.FlakeID
10
11 import Pleroma.Web.ApiSpec.Helpers
12
13 def open_api_operation(action) do
14 operation = String.to_existing_atom("#{action}_operation")
15 apply(__MODULE__, operation, [])
16 end
17
18 def index_operation do
19 %Operation{
20 tags: ["Conversations"],
21 summary: "List of conversations",
22 security: [%{"oAuth" => ["read:statuses"]}],
23 operationId: "ConversationController.index",
24 parameters: [
25 Operation.parameter(
26 :recipients,
27 :query,
28 %Schema{type: :array, items: FlakeID},
29 "Only return conversations with the given recipients (a list of user ids)"
30 )
31 | pagination_params()
32 ],
33 responses: %{
34 200 =>
35 Operation.response("Array of Conversation", "application/json", %Schema{
36 type: :array,
37 items: Conversation,
38 example: [Conversation.schema().example]
39 })
40 }
41 }
42 end
43
44 def mark_as_read_operation do
45 %Operation{
46 tags: ["Conversations"],
47 summary: "Mark conversation as read",
48 operationId: "ConversationController.mark_as_read",
49 parameters: [id_param()],
50 security: [%{"oAuth" => ["write:conversations"]}],
51 responses: %{
52 200 => Operation.response("Conversation", "application/json", Conversation)
53 }
54 }
55 end
56
57 def delete_operation do
58 %Operation{
59 tags: ["Conversations"],
60 summary: "Remove conversation",
61 operationId: "ConversationController.delete",
62 parameters: [id_param()],
63 security: [%{"oAuth" => ["write:conversations"]}],
64 responses: %{
65 200 => empty_object_response()
66 }
67 }
68 end
69
70 def id_param do
71 Operation.parameter(:id, :path, :string, "Conversation ID",
72 example: "123",
73 required: true
74 )
75 end
76 end