From a7e74ee01232897a6172f6462cec282a451c319a Mon Sep 17 00:00:00 2001 From: dtluna Date: Mon, 10 Apr 2017 20:08:14 +0300 Subject: [PATCH] Add user timeline --- lib/pleroma/web/router.ex | 1 + .../web/twitter_api/twitter_api_controller.ex | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 52030d684..8e6a2b012 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -33,6 +33,7 @@ defmodule Pleroma.Web.Router do post "/account/verify_credentials", TwitterAPI.Controller, :verify_credentials post "/statuses/update", TwitterAPI.Controller, :status_update get "/statuses/friends_timeline", TwitterAPI.Controller, :friends_timeline + get "/statuses/user_timeline", TwitterAPI.Controller, :user_timeline post "/friendships/create", TwitterAPI.Controller, :follow post "/friendships/destroy", TwitterAPI.Controller, :unfollow post "/statusnet/media/upload", TwitterAPI.Controller, :upload diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index f2c893e96..741689ebf 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -43,6 +43,26 @@ defmodule Pleroma.Web.TwitterAPI.Controller do |> json_reply(200, json) end + def user_timeline(conn, %{ "user_id" => user_id } = params) do + user = Repo.get(User, user_id) + conn = Map.merge(conn, %{assigns: %{user: user}}) + params = Map.delete(params, "user_id") + + friends_timeline(conn, params) + end + + def user_timeline(conn, %{ "screen_name" => nickname} = params) do + user = Repo.get_by!(User, nickname: nickname) + conn = Map.merge(conn, %{assigns: %{user: user}}) + params = Map.delete(params, "screen_name") + + friends_timeline(conn, params) + end + + def user_timeline(conn, params) do + friends_timeline(conn, params) + end + def follow(%{assigns: %{user: user}} = conn, %{ "user_id" => followed_id }) do { :ok, _user, follower, _activity } = TwitterAPI.follow(user, followed_id)