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
|> 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)