Add user timeline

This commit is contained in:
dtluna 2017-04-10 20:08:14 +03:00
parent b5e94bf930
commit a7e74ee012
2 changed files with 21 additions and 0 deletions

View file

@ -33,6 +33,7 @@ defmodule Pleroma.Web.Router do
post "/account/verify_credentials", TwitterAPI.Controller, :verify_credentials post "/account/verify_credentials", TwitterAPI.Controller, :verify_credentials
post "/statuses/update", TwitterAPI.Controller, :status_update post "/statuses/update", TwitterAPI.Controller, :status_update
get "/statuses/friends_timeline", TwitterAPI.Controller, :friends_timeline get "/statuses/friends_timeline", TwitterAPI.Controller, :friends_timeline
get "/statuses/user_timeline", TwitterAPI.Controller, :user_timeline
post "/friendships/create", TwitterAPI.Controller, :follow post "/friendships/create", TwitterAPI.Controller, :follow
post "/friendships/destroy", TwitterAPI.Controller, :unfollow post "/friendships/destroy", TwitterAPI.Controller, :unfollow
post "/statusnet/media/upload", TwitterAPI.Controller, :upload post "/statusnet/media/upload", TwitterAPI.Controller, :upload

View file

@ -43,6 +43,26 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|> json_reply(200, json) |> json_reply(200, json)
end 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 def follow(%{assigns: %{user: user}} = conn, %{ "user_id" => followed_id }) do
{ :ok, _user, follower, _activity } = TwitterAPI.follow(user, followed_id) { :ok, _user, follower, _activity } = TwitterAPI.follow(user, followed_id)