From: lambadalambda Date: Wed, 19 Apr 2017 09:50:24 +0000 (-0400) Subject: Merge branch 'feature/user-timeline' into 'develop' X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=eda742c78b0087033ee96f27c13dbdc00741cf87;p=akkoma Merge branch 'feature/user-timeline' into 'develop' Feature/user timeline See merge request !8 --- eda742c78b0087033ee96f27c13dbdc00741cf87 diff --cc lib/pleroma/web/router.ex index 0446f622b,d6cb970e9..b28813a45 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@@ -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 diff --cc lib/pleroma/web/twitter_api/twitter_api_controller.ex index 32d352d79,36e2d235b..8b5e6270b --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@@ -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