2020-05-19 11:52:26 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.ApiSpec.PleromaOperation do
|
|
|
|
alias OpenApiSpex.Operation
|
|
|
|
alias OpenApiSpex.Schema
|
2020-05-19 13:50:49 -06:00
|
|
|
alias Pleroma.Web.ApiSpec.NotificationOperation
|
2020-05-19 11:52:26 -06:00
|
|
|
alias Pleroma.Web.ApiSpec.Schemas.ApiError
|
|
|
|
|
|
|
|
def open_api_operation(action) do
|
|
|
|
operation = String.to_existing_atom("#{action}_operation")
|
|
|
|
apply(__MODULE__, operation, [])
|
|
|
|
end
|
|
|
|
|
|
|
|
def mark_notifications_as_read_operation do
|
|
|
|
%Operation{
|
|
|
|
tags: ["Notifications"],
|
|
|
|
summary: "Mark notifications as read. Query parameters are mutually exclusive.",
|
|
|
|
parameters: [
|
|
|
|
Operation.parameter(:id, :query, :string, "A single notification ID to read"),
|
|
|
|
Operation.parameter(:max_id, :query, :string, "Read all notifications up to this id")
|
|
|
|
],
|
|
|
|
security: [%{"oAuth" => ["write:notifications"]}],
|
|
|
|
operationId: "PleromaController.mark_notifications_as_read",
|
|
|
|
responses: %{
|
|
|
|
200 =>
|
|
|
|
Operation.response(
|
|
|
|
"A Notification or array of Motifications",
|
|
|
|
"application/json",
|
|
|
|
%Schema{
|
|
|
|
anyOf: [
|
|
|
|
%Schema{type: :array, items: NotificationOperation.notification()},
|
|
|
|
NotificationOperation.notification()
|
|
|
|
]
|
|
|
|
}
|
|
|
|
),
|
|
|
|
400 => Operation.response("Bad Request", "application/json", ApiError)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|