From: dtluna Date: Mon, 10 Apr 2017 17:08:14 +0000 (+0300) Subject: Add user timeline X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=a7e74ee01232897a6172f6462cec282a451c319a;p=akkoma Add user timeline --- 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)