diff options
author | lambadalambda <gitgud@rogerbraun.net> | 2017-04-19 05:50:24 -0400 |
---|---|---|
committer | lambadalambda <gitgud@rogerbraun.net> | 2017-04-19 05:50:24 -0400 |
commit | eda742c78b0087033ee96f27c13dbdc00741cf87 (patch) | |
tree | 3d81f27ec6da307a01c5e912dc939bbda95dbafe /lib/pleroma/web/twitter_api/twitter_api_controller.ex | |
parent | ac9817bdb0d911cffe1678bdf63de9e527a47b48 (diff) | |
parent | 470f5f7cd616852327706bae74bd1eddd653285f (diff) | |
download | pleroma-eda742c78b0087033ee96f27c13dbdc00741cf87.tar.gz |
Merge branch 'feature/user-timeline' into 'develop'
Feature/user timeline
See merge request !8
Diffstat (limited to 'lib/pleroma/web/twitter_api/twitter_api_controller.ex')
-rw-r--r-- | lib/pleroma/web/twitter_api/twitter_api_controller.ex | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 32d352d79..8b5e6270b 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -45,6 +45,18 @@ defmodule Pleroma.Web.TwitterAPI.Controller do |> 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 case TwitterAPI.follow(user, followed_id) do { :ok, user, followed, _activity } -> @@ -162,6 +174,11 @@ defmodule Pleroma.Web.TwitterAPI.Controller do |> json_reply(200, response) end + defp bad_request_reply(conn, error_message) do + json = Poison.encode!(%{"error" => error_message}) + json_reply(conn, 400, json) + end + defp json_reply(conn, status, json) do conn |> put_resp_content_type("application/json") |