2020-04-13 18:44:52 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2023-01-02 20:38:50 +00:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2020-04-13 18:44:52 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.ApiSpec.DomainBlockOperation do
|
|
|
|
alias OpenApiSpex.Operation
|
|
|
|
alias OpenApiSpex.Schema
|
2020-04-28 17:27:54 +00:00
|
|
|
import Pleroma.Web.ApiSpec.Helpers
|
2020-04-13 18:44:52 +00:00
|
|
|
|
|
|
|
def open_api_operation(action) do
|
|
|
|
operation = String.to_existing_atom("#{action}_operation")
|
|
|
|
apply(__MODULE__, operation, [])
|
|
|
|
end
|
|
|
|
|
|
|
|
def index_operation do
|
|
|
|
%Operation{
|
2021-02-03 12:38:59 +00:00
|
|
|
tags: ["Domain blocks"],
|
|
|
|
summary: "Retrieve a list of blocked domains",
|
2020-04-13 18:44:52 +00:00
|
|
|
security: [%{"oAuth" => ["follow", "read:blocks"]}],
|
|
|
|
operationId: "DomainBlockController.index",
|
|
|
|
responses: %{
|
2020-04-24 10:46:59 +00:00
|
|
|
200 =>
|
|
|
|
Operation.response("Domain blocks", "application/json", %Schema{
|
|
|
|
description: "Response schema for domain blocks",
|
|
|
|
type: :array,
|
|
|
|
items: %Schema{type: :string},
|
|
|
|
example: ["google.com", "facebook.com"]
|
|
|
|
})
|
2020-04-13 18:44:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-07-23 17:59:40 +00:00
|
|
|
# Supporting domain query parameter is deprecated in Mastodon API
|
2020-04-13 18:44:52 +00:00
|
|
|
def create_operation do
|
|
|
|
%Operation{
|
2021-02-03 12:38:59 +00:00
|
|
|
tags: ["Domain blocks"],
|
2020-04-13 18:44:52 +00:00
|
|
|
summary: "Block a domain",
|
|
|
|
description: """
|
|
|
|
Block a domain to:
|
|
|
|
|
|
|
|
- hide all public posts from it
|
|
|
|
- hide all notifications from it
|
|
|
|
- remove all followers from it
|
|
|
|
- prevent following new users from it (but does not remove existing follows)
|
|
|
|
""",
|
|
|
|
operationId: "DomainBlockController.create",
|
2020-04-24 10:46:59 +00:00
|
|
|
requestBody: domain_block_request(),
|
2020-07-23 17:59:40 +00:00
|
|
|
parameters: [Operation.parameter(:domain, :query, %Schema{type: :string}, "Domain name")],
|
2020-04-13 18:44:52 +00:00
|
|
|
security: [%{"oAuth" => ["follow", "write:blocks"]}],
|
2020-04-28 17:27:54 +00:00
|
|
|
responses: %{200 => empty_object_response()}
|
2020-04-13 18:44:52 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2020-07-23 17:59:40 +00:00
|
|
|
# Supporting domain query parameter is deprecated in Mastodon API
|
2020-04-13 18:44:52 +00:00
|
|
|
def delete_operation do
|
|
|
|
%Operation{
|
2021-02-03 12:38:59 +00:00
|
|
|
tags: ["Domain blocks"],
|
2020-04-13 18:44:52 +00:00
|
|
|
summary: "Unblock a domain",
|
|
|
|
description: "Remove a domain block, if it exists in the user's array of blocked domains.",
|
|
|
|
operationId: "DomainBlockController.delete",
|
2020-04-24 10:46:59 +00:00
|
|
|
requestBody: domain_block_request(),
|
2020-07-21 12:06:46 +00:00
|
|
|
parameters: [Operation.parameter(:domain, :query, %Schema{type: :string}, "Domain name")],
|
2020-04-13 18:44:52 +00:00
|
|
|
security: [%{"oAuth" => ["follow", "write:blocks"]}],
|
|
|
|
responses: %{
|
|
|
|
200 => Operation.response("Empty object", "application/json", %Schema{type: :object})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
2020-04-24 10:46:59 +00:00
|
|
|
|
|
|
|
defp domain_block_request do
|
2020-04-28 17:27:54 +00:00
|
|
|
request_body(
|
2020-04-24 10:46:59 +00:00
|
|
|
"Parameters",
|
|
|
|
%Schema{
|
|
|
|
type: :object,
|
|
|
|
properties: %{
|
Pleroma.Web.MastodonAPI.DomainBlockController: dialyzer errors
lib/pleroma/web/mastodon_api/controllers/domain_block_controller.ex:32:call
The function call will not succeed.
Phoenix.Controller.json(
_conn :: %{
:assigns => %{:user => _, _ => _},
:body_params => %{:domain => _, _ => _},
_ => _
},
%{}
)
breaks the contract
(Plug.Conn.t(), term()) :: Plug.Conn.t()
________________________________________________________________________________
lib/pleroma/web/mastodon_api/controllers/domain_block_controller.ex:43:call
The function call will not succeed.
Phoenix.Controller.json(
_conn :: %{
:assigns => %{:user => _, _ => _},
:body_params => %{:domain => _, _ => _},
_ => _
},
%{}
)
breaks the contract
(Plug.Conn.t(), term()) :: Plug.Conn.t()
2024-01-29 22:44:54 +00:00
|
|
|
"domain" => %Schema{type: :string}
|
2020-07-21 12:06:46 +00:00
|
|
|
}
|
2020-04-24 10:46:59 +00:00
|
|
|
},
|
Pleroma.Web.MastodonAPI.DomainBlockController: dialyzer errors
lib/pleroma/web/mastodon_api/controllers/domain_block_controller.ex:32:call
The function call will not succeed.
Phoenix.Controller.json(
_conn :: %{
:assigns => %{:user => _, _ => _},
:body_params => %{:domain => _, _ => _},
_ => _
},
%{}
)
breaks the contract
(Plug.Conn.t(), term()) :: Plug.Conn.t()
________________________________________________________________________________
lib/pleroma/web/mastodon_api/controllers/domain_block_controller.ex:43:call
The function call will not succeed.
Phoenix.Controller.json(
_conn :: %{
:assigns => %{:user => _, _ => _},
:body_params => %{:domain => _, _ => _},
_ => _
},
%{}
)
breaks the contract
(Plug.Conn.t(), term()) :: Plug.Conn.t()
2024-01-29 22:44:54 +00:00
|
|
|
required: true,
|
2020-04-24 10:46:59 +00:00
|
|
|
example: %{
|
|
|
|
"domain" => "facebook.com"
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
2020-04-13 18:44:52 +00:00
|
|
|
end
|