From 8a97bebc5349dc4b388567ce8c7335a51c2427f3 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Thu, 24 Aug 2017 14:07:05 +0200 Subject: [PATCH] More meta info fixes. --- lib/pleroma/web/router.ex | 11 ++++- .../controllers/util_controller.ex | 41 +++++++++++++++---- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index f88b71915..585642c33 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -23,12 +23,21 @@ def user_fetcher(username) do plug :accepts, ["xml", "xrd+xml"] end + pipeline :config do + plug :accepts, ["json", "xml"] + end + scope "/api", Pleroma.Web do - pipe_through :api + pipe_through :config get "/help/test", TwitterAPI.UtilController, :help_test post "/help/test", TwitterAPI.UtilController, :help_test get "/statusnet/config", TwitterAPI.UtilController, :config + get "/statusnet/version", TwitterAPI.UtilController, :version + end + + scope "/api", Pleroma.Web do + pipe_through :api get "/statuses/public_timeline", TwitterAPI.Controller, :public_timeline get "/statuses/public_and_external_timeline", TwitterAPI.Controller, :public_and_external_timeline diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex index 2bcae74ce..41881e742 100644 --- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex +++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex @@ -7,12 +7,39 @@ def help_test(conn, _params) do end def config(conn, _params) do - json(conn, %{ - site: %{ - name: Web.base_url, - server: Web.base_url, - textlimit: 5000 - } - }) + case get_format(conn) do + "xml" -> + response = """ + + + #{Web.base_url} + #{Web.base_url} + 5000 + + + """ + conn + |> put_resp_content_type("application/xml") + |> send_resp(200, response) + _ -> + json(conn, %{ + site: %{ + name: Web.base_url, + server: Web.base_url, + textlimit: 5000 + } + }) + end + end + + def version(conn, _params) do + case get_format(conn) do + "xml" -> + response = "Pleroma Dev" + conn + |> put_resp_content_type("application/xml") + |> send_resp(200, response) + _ -> json(conn, "Pleroma Dev") + end end end