2022-03-08 17:07:21 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-02 20:38:50 +00:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2022-03-08 17:07:21 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.ApiSpec.AnnouncementOperation do
|
|
|
|
alias OpenApiSpex.Operation
|
|
|
|
alias OpenApiSpex.Schema
|
|
|
|
alias Pleroma.Web.ApiSpec.Schemas.Announcement
|
|
|
|
alias Pleroma.Web.ApiSpec.Schemas.ApiError
|
|
|
|
|
|
|
|
def open_api_operation(action) do
|
|
|
|
operation = String.to_existing_atom("#{action}_operation")
|
|
|
|
apply(__MODULE__, operation, [])
|
|
|
|
end
|
|
|
|
|
|
|
|
def index_operation do
|
|
|
|
%Operation{
|
2023-01-15 23:31:37 +00:00
|
|
|
tags: ["Announcements"],
|
2022-03-08 17:07:21 +00:00
|
|
|
summary: "Retrieve a list of announcements",
|
|
|
|
operationId: "MastodonAPI.AnnouncementController.index",
|
2022-04-02 06:25:13 +00:00
|
|
|
security: [%{"oAuth" => []}],
|
2022-03-08 17:07:21 +00:00
|
|
|
responses: %{
|
|
|
|
200 => Operation.response("Response", "application/json", list_of_announcements()),
|
|
|
|
403 => Operation.response("Forbidden", "application/json", ApiError)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def mark_read_operation do
|
|
|
|
%Operation{
|
2023-01-15 23:31:37 +00:00
|
|
|
tags: ["Announcements"],
|
2022-03-08 17:07:21 +00:00
|
|
|
summary: "Mark one announcement as read",
|
|
|
|
operationId: "MastodonAPI.AnnouncementController.mark_read",
|
|
|
|
security: [%{"oAuth" => ["write:accounts"]}],
|
|
|
|
parameters: [
|
|
|
|
Operation.parameter(
|
|
|
|
:id,
|
|
|
|
:path,
|
|
|
|
:string,
|
|
|
|
"announcement id"
|
|
|
|
)
|
|
|
|
],
|
|
|
|
responses: %{
|
2022-03-08 21:59:20 +00:00
|
|
|
200 => Operation.response("Response", "application/json", %Schema{type: :object}),
|
2022-03-08 17:07:21 +00:00
|
|
|
403 => Operation.response("Forbidden", "application/json", ApiError),
|
|
|
|
404 => Operation.response("Not Found", "application/json", ApiError)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def list_of_announcements do
|
|
|
|
%Schema{
|
|
|
|
type: :array,
|
|
|
|
items: Announcement
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|