Merge branch 'chores/bump-copyright' into 'develop'
[akkoma] / lib / pleroma / web / api_spec / operations / pleroma_notification_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.PleromaNotificationOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.NotificationOperation
9 alias Pleroma.Web.ApiSpec.Schemas.ApiError
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 mark_as_read_operation do
19 %Operation{
20 tags: ["Notifications"],
21 summary: "Mark notifications as read. Query parameters are mutually exclusive.",
22 requestBody:
23 request_body("Parameters", %Schema{
24 type: :object,
25 properties: %{
26 id: %Schema{type: :integer, description: "A single notification ID to read"},
27 max_id: %Schema{type: :integer, description: "Read all notifications up to this ID"}
28 }
29 }),
30 security: [%{"oAuth" => ["write:notifications"]}],
31 operationId: "PleromaAPI.NotificationController.mark_as_read",
32 responses: %{
33 200 =>
34 Operation.response(
35 "A Notification or array of Motifications",
36 "application/json",
37 %Schema{
38 anyOf: [
39 %Schema{type: :array, items: NotificationOperation.notification()},
40 NotificationOperation.notification()
41 ]
42 }
43 ),
44 400 => Operation.response("Bad Request", "application/json", ApiError)
45 }
46 }
47 end
48 end