add remote user count for the heck of it
[akkoma] / lib / pleroma / web / api_spec / operations / announcement_operation.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ApiSpec.AnnouncementOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Schemas.Announcement
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 index_operation do
17 %Operation{
18 tags: ["Announcement"],
19 summary: "Retrieve a list of announcements",
20 operationId: "MastodonAPI.AnnouncementController.index",
21 security: [%{"oAuth" => []}],
22 responses: %{
23 200 => Operation.response("Response", "application/json", list_of_announcements()),
24 403 => Operation.response("Forbidden", "application/json", ApiError)
25 }
26 }
27 end
28
29 def mark_read_operation do
30 %Operation{
31 tags: ["Announcement"],
32 summary: "Mark one announcement as read",
33 operationId: "MastodonAPI.AnnouncementController.mark_read",
34 security: [%{"oAuth" => ["write:accounts"]}],
35 parameters: [
36 Operation.parameter(
37 :id,
38 :path,
39 :string,
40 "announcement id"
41 )
42 ],
43 responses: %{
44 200 => Operation.response("Response", "application/json", %Schema{type: :object}),
45 403 => Operation.response("Forbidden", "application/json", ApiError),
46 404 => Operation.response("Not Found", "application/json", ApiError)
47 }
48 }
49 end
50
51 def list_of_announcements do
52 %Schema{
53 type: :array,
54 items: Announcement
55 }
56 end
57 end