1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ApiSpec.TimelineOperation do
6 alias OpenApiSpex.Operation
7 alias OpenApiSpex.Schema
8 alias Pleroma.Web.ApiSpec.Schemas.ApiError
9 alias Pleroma.Web.ApiSpec.Schemas.BooleanLike
10 alias Pleroma.Web.ApiSpec.Schemas.Status
11 alias Pleroma.Web.ApiSpec.Schemas.VisibilityScope
13 import Pleroma.Web.ApiSpec.Helpers
15 def open_api_operation(action) do
16 operation = String.to_existing_atom("#{action}_operation")
17 apply(__MODULE__, operation, [])
23 summary: "Home timeline",
24 description: "View statuses from followed users",
25 security: [%{"oAuth" => ["read:statuses"]}],
29 exclude_visibilities_param(),
30 reply_visibility_param() | pagination_params()
32 operationId: "TimelineController.home",
34 200 => Operation.response("Array of Status", "application/json", array_of_statuses())
39 def direct_operation do
42 summary: "Direct timeline",
44 "View statuses with a “direct” privacy, from your account or in your notifications",
46 parameters: [with_muted_param() | pagination_params()],
47 security: [%{"oAuth" => ["read:statuses"]}],
48 operationId: "TimelineController.direct",
50 200 => Operation.response("Array of Status", "application/json", array_of_statuses())
55 def public_operation do
58 summary: "Public timeline",
59 security: [%{"oAuth" => ["read:statuses"]}],
64 exclude_visibilities_param(),
65 reply_visibility_param() | pagination_params()
67 operationId: "TimelineController.public",
69 200 => Operation.response("Array of Status", "application/json", array_of_statuses()),
70 401 => Operation.response("Error", "application/json", ApiError)
75 def hashtag_operation do
78 summary: "Hashtag timeline",
79 description: "View public statuses containing the given hashtag",
80 security: [%{"oAuth" => ["read:statuses"]}],
85 %Schema{type: :string},
86 "Content of a #hashtag, not including # symbol.",
92 %Schema{type: :array, items: %Schema{type: :string}},
93 "Statuses that also includes any of these tags"
98 %Schema{type: :array, items: %Schema{type: :string}},
99 "Statuses that also includes all of these tags"
104 %Schema{type: :array, items: %Schema{type: :string}},
105 "Statuses that do not include these tags"
110 exclude_visibilities_param() | pagination_params()
112 operationId: "TimelineController.hashtag",
114 200 => Operation.response("Array of Status", "application/json", array_of_statuses())
119 def list_operation do
122 summary: "List timeline",
123 description: "View statuses in the given list timeline",
124 security: [%{"oAuth" => ["read:lists"]}],
129 %Schema{type: :string},
130 "Local ID of the list in the database",
134 exclude_visibilities_param() | pagination_params()
136 operationId: "TimelineController.list",
138 200 => Operation.response("Array of Status", "application/json", array_of_statuses())
143 defp array_of_statuses do
145 title: "ArrayOfStatuses",
148 example: [Status.schema().example]
156 %Schema{allOf: [BooleanLike], default: false},
157 "Show only local statuses?"
161 defp with_muted_param do
162 Operation.parameter(:with_muted, :query, BooleanLike, "Includeactivities by muted users")
165 defp exclude_visibilities_param do
167 :exclude_visibilities,
169 %Schema{type: :array, items: VisibilityScope},
170 "Exclude the statuses with the given visibilities"
174 defp reply_visibility_param do
178 %Schema{type: :string, enum: ["following", "self"]},
179 "Filter replies. Possible values: without parameter (default) shows all replies, `following` - replies directed to you or users you follow, `self` - replies directed to you."
183 defp only_media_param do
187 %Schema{allOf: [BooleanLike], default: false},
188 "Show only statuses with media attached?"