Merge branch 'feature/user-timeline' into 'develop'
authorlambadalambda <gitgud@rogerbraun.net>
Wed, 19 Apr 2017 09:50:24 +0000 (05:50 -0400)
committerlambadalambda <gitgud@rogerbraun.net>
Wed, 19 Apr 2017 09:50:24 +0000 (05:50 -0400)
Feature/user timeline

See merge request !8

1  2 
lib/pleroma/web/router.ex
lib/pleroma/web/twitter_api/twitter_api.ex
lib/pleroma/web/twitter_api/twitter_api_controller.ex
test/web/twitter_api/twitter_api_controller_test.exs
test/web/twitter_api/twitter_api_test.exs

index 0446f622b6ce346f568b954b6a272c2649a110bc,d6cb970e90667cadca55c3f317df47bb63c7b346..b28813a456997dfee793eed9200f84b8703e49af
@@@ -21,10 -21,9 +21,11 @@@ defmodule Pleroma.Web.Router d
  
    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
index 32d352d797641d8e727244004cad0741152b41cf,36e2d235be4461f139fe3dfa1bbe78d914b85e9b..8b5e6270bc95fc15d9b654011927d1a31fc64ca4
@@@ -45,14 -45,25 +45,26 @@@ defmodule Pleroma.Web.TwitterAPI.Contro
      |> 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