scope "/api", Pleroma.Web do
pipe_through :api
+
+ get "/help/test", TwitterAPI.Controller, :help_test
get "/statuses/public_timeline", TwitterAPI.Controller, :public_timeline
get "/statuses/public_and_external_timeline", TwitterAPI.Controller, :public_timeline
+ get "/statuses/user_timeline", TwitterAPI.Controller, :user_timeline
get "/statuses/show/:id", TwitterAPI.Controller, :fetch_status
get "/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation
get "/statusnet/config", TwitterAPI.Controller, :config
|> json_reply(200, json)
end
+ def user_timeline(%{assigns: %{user: user}} = conn, params) do
+ case TwitterAPI.get_user(user, params) do
+ {:ok, target_user} ->
+ params = Map.merge(params, %{"actor_id" => target_user.ap_id})
+ statuses = TwitterAPI.fetch_user_statuses(user, params)
+ conn
+ |> json_reply(200, statuses |> Poison.encode!)
+ {:error, msg} ->
+ bad_request_reply(conn, msg)
+ end
+ end
+
def follow(%{assigns: %{user: user}} = conn, %{ "user_id" => followed_id }) do
- { :ok, user, follower, _activity } = TwitterAPI.follow(user, followed_id)
-
- response = follower |> UserRepresenter.to_json(%{for: user})
-
- conn
- |> json_reply(200, response)
+ case TwitterAPI.follow(user, followed_id) do
+ { :ok, user, followed, _activity } ->
+ response = followed |> UserRepresenter.to_json(%{for: user})
+ conn
+ |> json_reply(200, response)
+ { :error, msg } -> forbidden_json_reply(conn, msg)
+ end
end
def unfollow(%{assigns: %{user: user}} = conn, %{ "user_id" => followed_id }) do