Add GET /api/v1/instance/rules
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
bd52e2aec7
commit
432599311d
|
@ -17,7 +17,7 @@ def open_api_operation(action) do
|
||||||
def index_operation do
|
def index_operation do
|
||||||
%Operation{
|
%Operation{
|
||||||
tags: ["Instance rule managment"],
|
tags: ["Instance rule managment"],
|
||||||
summary: "Retrieve a list of instance rules",
|
summary: "Retrieve list of instance rules",
|
||||||
operationId: "AdminAPI.RuleController.index",
|
operationId: "AdminAPI.RuleController.index",
|
||||||
security: [%{"oAuth" => ["admin:read"]}],
|
security: [%{"oAuth" => ["admin:read"]}],
|
||||||
responses: %{
|
responses: %{
|
||||||
|
|
|
@ -34,6 +34,17 @@ def peers_operation do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def rules_operation do
|
||||||
|
%Operation{
|
||||||
|
tags: ["Instance"],
|
||||||
|
summary: "Retrieve list of instance rules",
|
||||||
|
operationId: "InstanceController.rules",
|
||||||
|
responses: %{
|
||||||
|
200 => Operation.response("Array of domains", "application/json", array_of_rules())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
defp instance do
|
defp instance do
|
||||||
%Schema{
|
%Schema{
|
||||||
type: :object,
|
type: :object,
|
||||||
|
@ -160,7 +171,8 @@ defp instance do
|
||||||
"urls" => %{
|
"urls" => %{
|
||||||
"streaming_api" => "wss://lain.com"
|
"streaming_api" => "wss://lain.com"
|
||||||
},
|
},
|
||||||
"version" => "2.7.2 (compatible; Pleroma 2.0.50-536-g25eec6d7-develop)"
|
"version" => "2.7.2 (compatible; Pleroma 2.0.50-536-g25eec6d7-develop)",
|
||||||
|
"rules" => array_of_rules()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -172,4 +184,17 @@ defp array_of_domains do
|
||||||
example: ["pleroma.site", "lain.com", "bikeshed.party"]
|
example: ["pleroma.site", "lain.com", "bikeshed.party"]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp array_of_rules do
|
||||||
|
%Schema{
|
||||||
|
type: :array,
|
||||||
|
items: %Schema{
|
||||||
|
type: :object,
|
||||||
|
properties: %{
|
||||||
|
id: %Schema{type: :integer},
|
||||||
|
text: %Schema{type: :string}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,4 +20,9 @@ def show(conn, _params) do
|
||||||
def peers(conn, _params) do
|
def peers(conn, _params) do
|
||||||
json(conn, Pleroma.Stats.get_peers())
|
json(conn, Pleroma.Stats.get_peers())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@doc "GET /api/v1/instance/rules"
|
||||||
|
def rules(conn, _params) do
|
||||||
|
render(conn, "rules.json")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -58,6 +58,10 @@ def render("show.json", _) do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render("rules.json", _) do
|
||||||
|
rules()
|
||||||
|
end
|
||||||
|
|
||||||
def features do
|
def features do
|
||||||
[
|
[
|
||||||
"pleroma_api",
|
"pleroma_api",
|
||||||
|
|
|
@ -606,6 +606,7 @@ defmodule Pleroma.Web.Router do
|
||||||
|
|
||||||
get("/instance", InstanceController, :show)
|
get("/instance", InstanceController, :show)
|
||||||
get("/instance/peers", InstanceController, :peers)
|
get("/instance/peers", InstanceController, :peers)
|
||||||
|
get("/instance/rules", InstanceController, :rules)
|
||||||
|
|
||||||
get("/statuses", StatusController, :index)
|
get("/statuses", StatusController, :index)
|
||||||
get("/statuses/:id", StatusController, :show)
|
get("/statuses/:id", StatusController, :show)
|
||||||
|
|
Loading…
Reference in New Issue