Move notification actions to PleromaAPI.NotificationController
[akkoma] / lib / pleroma / web / api_spec / operations / pleroma_notification_operation.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 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 def open_api_operation(action) do
12 operation = String.to_existing_atom("#{action}_operation")
13 apply(__MODULE__, operation, [])
14 end
15
16 def mark_as_read_operation do
17 %Operation{
18 tags: ["Notifications"],
19 summary: "Mark notifications as read. Query parameters are mutually exclusive.",
20 parameters: [
21 Operation.parameter(:id, :query, :string, "A single notification ID to read"),
22 Operation.parameter(:max_id, :query, :string, "Read all notifications up to this id")
23 ],
24 security: [%{"oAuth" => ["write:notifications"]}],
25 operationId: "PleromaAPI.NotificationController.mark_as_read",
26 responses: %{
27 200 =>
28 Operation.response(
29 "A Notification or array of Motifications",
30 "application/json",
31 %Schema{
32 anyOf: [
33 %Schema{type: :array, items: NotificationOperation.notification()},
34 NotificationOperation.notification()
35 ]
36 }
37 ),
38 400 => Operation.response("Bad Request", "application/json", ApiError)
39 }
40 }
41 end
42 end