diff options
author | Roger Braun <rbraun@Bobble.local> | 2017-09-13 17:36:02 +0200 |
---|---|---|
committer | Roger Braun <rbraun@Bobble.local> | 2017-09-13 17:36:02 +0200 |
commit | d168ef5a9eb4fc074b042a6dea6d7971d1972c06 (patch) | |
tree | 914116610735a11d785e88e7df62dc12a5bb6d34 /lib | |
parent | ad5001828ec77cf9fdf4bfb93ad53568a66bfe8b (diff) | |
download | pleroma-d168ef5a9eb4fc074b042a6dea6d7971d1972c06.tar.gz |
MastoAPI: Add accounts getting.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/mastodon_api/mastodon_api_controller.ex | 11 | ||||
-rw-r--r-- | lib/pleroma/web/router.ex | 27 |
2 files changed, 25 insertions, 13 deletions
diff --git a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex index 14f7eeeb6..f17cf40e6 100644 --- a/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex +++ b/lib/pleroma/web/mastodon_api/mastodon_api_controller.ex @@ -28,6 +28,17 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do json(conn, account) end + def user(conn, %{"id" => id}) do + with %User{} = user <- Repo.get(User, id) do + account = AccountView.render("account.json", %{user: user}) + json(conn, account) + else + _e -> conn + |> put_status(404) + |> json(%{error: "Can't find user"}) + end + end + def masto_instance(conn, _params) do response = %{ uri: Web.base_url, diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 883fd56f4..0bd8e40c4 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -40,19 +40,6 @@ defmodule Pleroma.Web.Router do end scope "/api/v1", Pleroma.Web.MastodonAPI do - pipe_through :api - get "/instance", MastodonAPIController, :masto_instance - post "/apps", MastodonAPIController, :create_app - - get "/timelines/public", MastodonAPIController, :public_timeline - - get "/statuses/:id", MastodonAPIController, :get_status - get "/statuses/:id/context", MastodonAPIController, :get_context - - get "/accounts/:id/statuses", MastodonAPIController, :user_statuses - end - - scope "/api/v1", Pleroma.Web.MastodonAPI do pipe_through :authenticated_api get "/accounts/verify_credentials", MastodonAPIController, :verify_credentials @@ -70,6 +57,20 @@ defmodule Pleroma.Web.Router do get "/notifications", MastodonAPIController, :notifications end + scope "/api/v1", Pleroma.Web.MastodonAPI do + pipe_through :api + get "/instance", MastodonAPIController, :masto_instance + post "/apps", MastodonAPIController, :create_app + + get "/timelines/public", MastodonAPIController, :public_timeline + + get "/statuses/:id", MastodonAPIController, :get_status + get "/statuses/:id/context", MastodonAPIController, :get_context + + get "/accounts/:id/statuses", MastodonAPIController, :user_statuses + get "/accounts/:id", MastodonAPIController, :user + end + scope "/api", Pleroma.Web do pipe_through :config |