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(),
31 with_relationships_param() | pagination_params()
33 operationId: "TimelineController.home",
35 200 => Operation.response("Array of Status", "application/json", array_of_statuses())
40 def direct_operation do
43 summary: "Direct timeline",
45 "View statuses with a “direct” privacy, from your account or in your notifications",
47 parameters: pagination_params(),
48 security: [%{"oAuth" => ["read:statuses"]}],
49 operationId: "TimelineController.direct",
51 200 => Operation.response("Array of Status", "application/json", array_of_statuses())
56 def public_operation do
59 summary: "Public timeline",
60 security: [%{"oAuth" => ["read:statuses"]}],
65 exclude_visibilities_param(),
66 reply_visibility_param(),
67 with_relationships_param() | pagination_params()
69 operationId: "TimelineController.public",
71 200 => Operation.response("Array of Status", "application/json", array_of_statuses()),
72 401 => Operation.response("Error", "application/json", ApiError)
77 def hashtag_operation do
80 summary: "Hashtag timeline",
81 description: "View public statuses containing the given hashtag",
82 security: [%{"oAuth" => ["read:statuses"]}],
87 %Schema{type: :string},
88 "Content of a #hashtag, not including # symbol.",
94 %Schema{type: :array, items: %Schema{type: :string}},
95 "Statuses that also includes any of these tags"
100 %Schema{type: :array, items: %Schema{type: :string}},
101 "Statuses that also includes all of these tags"
106 %Schema{type: :array, items: %Schema{type: :string}},
107 "Statuses that do not include these tags"
112 exclude_visibilities_param(),
113 with_relationships_param() | pagination_params()
115 operationId: "TimelineController.hashtag",
117 200 => Operation.response("Array of Status", "application/json", array_of_statuses())
122 def list_operation do
125 summary: "List timeline",
126 description: "View statuses in the given list timeline",
127 security: [%{"oAuth" => ["read:lists"]}],
132 %Schema{type: :string},
133 "Local ID of the list in the database",
137 exclude_visibilities_param(),
138 with_relationships_param() | pagination_params()
140 operationId: "TimelineController.list",
142 200 => Operation.response("Array of Status", "application/json", array_of_statuses())
147 defp array_of_statuses do
149 title: "ArrayOfStatuses",
152 example: [Status.schema().example]
156 defp with_relationships_param do
157 Operation.parameter(:with_relationships, :query, BooleanLike, "Include relationships")
164 %Schema{allOf: [BooleanLike], default: false},
165 "Show only local statuses?"
169 defp with_muted_param do
170 Operation.parameter(:with_muted, :query, BooleanLike, "Includeactivities by muted users")
173 defp exclude_visibilities_param do
175 :exclude_visibilities,
177 %Schema{type: :array, items: VisibilityScope},
178 "Exclude the statuses with the given visibilities"
182 defp reply_visibility_param do
186 %Schema{type: :string, enum: ["following", "self"]},
187 "Filter replies. Possible values: without parameter (default) shows all replies, `following` - replies directed to you or users you follow, `self` - replies directed to you."
191 defp only_media_param do
195 %Schema{allOf: [BooleanLike], default: false},
196 "Show only statuses with media attached?"