fix for unique oban worker option
[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: "Show conversation",
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 as read",
48 operationId: "ConversationController.mark_as_read",
49 parameters: [
50 Operation.parameter(:id, :path, :string, "Conversation ID",
51 example: "123",
52 required: true
53 )
54 ],
55 security: [%{"oAuth" => ["write:conversations"]}],
56 responses: %{
57 200 => Operation.response("Conversation", "application/json", Conversation)
58 }
59 }
60 end
61 end