Add externalprofile to TwAPI.
This commit is contained in:
parent
2e753e8cd7
commit
36448d6483
5 changed files with 38 additions and 0 deletions
|
|
@ -38,6 +38,8 @@ defmodule Pleroma.Web.Router do
|
|||
get "/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation
|
||||
|
||||
post "/account/register", TwitterAPI.Controller, :register
|
||||
|
||||
get "/externalprofile/show", TwitterAPI.Controller, :external_profile
|
||||
end
|
||||
|
||||
scope "/api", Pleroma.Web do
|
||||
|
|
|
|||
|
|
@ -350,4 +350,12 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
|||
{:error, "No such conversation"}
|
||||
end
|
||||
end
|
||||
|
||||
def get_external_profile(for_user, uri) do
|
||||
with %User{} = user <- User.get_cached_by_ap_id(uri) do
|
||||
{:ok, UserRepresenter.to_map(user, %{for: for_user})}
|
||||
else _e ->
|
||||
{:error, "Couldn't find user"}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -207,6 +207,14 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||
|> json_reply(200, response)
|
||||
end
|
||||
|
||||
def external_profile(%{assigns: %{user: current_user}} = conn, %{"profileurl" => uri}) do
|
||||
with {:ok, user_map} <- TwitterAPI.get_external_profile(current_user, uri),
|
||||
response <- Poison.encode!(user_map) do
|
||||
conn
|
||||
|> json_reply(200, response)
|
||||
end
|
||||
end
|
||||
|
||||
defp bad_request_reply(conn, error_message) do
|
||||
json = error_json(conn, error_message)
|
||||
json_reply(conn, 400, json)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue