use nodeinfo 2.1, add repository field

that is the only change from nodeinfo 2.0 to 2.1

also this makes the nodeinfo tests use 2.1.json instead of 2.0.json
This commit is contained in:
Luna 2019-02-01 03:55:10 -03:00
parent 0340fcaeca
commit c05928dbda
3 changed files with 14 additions and 11 deletions

View file

@ -8,9 +8,11 @@ defmodule Pleroma.Application do
@name "Pleroma" @name "Pleroma"
@version Mix.Project.config()[:version] @version Mix.Project.config()[:version]
@repository "https://git.pleroma.social/pleroma/pleroma"
def name, do: @name def name, do: @name
def version, do: @version def version, do: @version
def named_version(), do: @name <> " " <> @version def named_version(), do: @name <> " " <> @version
def repository, do: @repository
def user_agent() do def user_agent() do
info = "#{Pleroma.Web.base_url()} <#{Pleroma.Config.get([:instance, :email], "")}>" info = "#{Pleroma.Web.base_url()} <#{Pleroma.Config.get([:instance, :email], "")}>"

View file

@ -17,8 +17,8 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
response = %{ response = %{
links: [ links: [
%{ %{
rel: "http://nodeinfo.diaspora.software/ns/schema/2.0", rel: "http://nodeinfo.diaspora.software/ns/schema/2.1",
href: Web.base_url() <> "/nodeinfo/2.0.json" href: Web.base_url() <> "/nodeinfo/2.1.json"
} }
] ]
} }
@ -26,8 +26,8 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
json(conn, response) json(conn, response)
end end
# Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json # Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.1/schema.json
def nodeinfo(conn, %{"version" => "2.0"}) do def nodeinfo(conn, %{"version" => "2.1"}) do
instance = Application.get_env(:pleroma, :instance) instance = Application.get_env(:pleroma, :instance)
media_proxy = Application.get_env(:pleroma, :media_proxy) media_proxy = Application.get_env(:pleroma, :media_proxy)
suggestions = Application.get_env(:pleroma, :suggestions) suggestions = Application.get_env(:pleroma, :suggestions)
@ -99,10 +99,11 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
|> Enum.filter(& &1) |> Enum.filter(& &1)
response = %{ response = %{
version: "2.0", version: "2.1",
software: %{ software: %{
name: Pleroma.Application.name(), name: Pleroma.Application.name(),
version: Pleroma.Application.version() version: Pleroma.Application.version(),
repository: Pleroma.Application.repository(),
}, },
protocols: ["ostatus", "activitypub"], protocols: ["ostatus", "activitypub"],
services: %{ services: %{
@ -146,7 +147,7 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
conn conn
|> put_resp_header( |> put_resp_header(
"content-type", "content-type",
"application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.0#; charset=utf-8" "application/json; profile=http://nodeinfo.diaspora.software/ns/schema/2.1#; charset=utf-8"
) )
|> json(response) |> json(response)
end end

View file

@ -12,7 +12,7 @@ defmodule Pleroma.Web.NodeInfoTest do
conn = conn =
conn conn
|> get("/nodeinfo/2.0.json") |> get("/nodeinfo/2.1.json")
assert result = json_response(conn, 200) assert result = json_response(conn, 200)
@ -22,7 +22,7 @@ defmodule Pleroma.Web.NodeInfoTest do
test "nodeinfo shows restricted nicknames", %{conn: conn} do test "nodeinfo shows restricted nicknames", %{conn: conn} do
conn = conn =
conn conn
|> get("/nodeinfo/2.0.json") |> get("/nodeinfo/2.1.json")
assert result = json_response(conn, 200) assert result = json_response(conn, 200)
@ -42,7 +42,7 @@ defmodule Pleroma.Web.NodeInfoTest do
|> json_response(404) |> json_response(404)
conn conn
|> get("/nodeinfo/2.0.json") |> get("/nodeinfo/2.1.json")
|> json_response(404) |> json_response(404)
instance = instance =
@ -58,7 +58,7 @@ defmodule Pleroma.Web.NodeInfoTest do
|> json_response(200) |> json_response(200)
conn conn
|> get("/nodeinfo/2.0.json") |> get("/nodeinfo/2.1.json")
|> json_response(200) |> json_response(200)
end end
end end