Enable user timelines.

This commit is contained in:
Roger Braun 2017-06-12 17:12:55 +02:00
parent a1cabeea4a
commit eb18b9ebba
14 changed files with 12 additions and 2 deletions

View File

@ -33,6 +33,7 @@ def user_fetcher(username) do
get "/statuses/public_and_external_timeline", TwitterAPI.Controller, :public_and_external_timeline
get "/statuses/networkpublic_timeline", TwitterAPI.Controller, :public_and_external_timeline
get "/statuses/user_timeline", TwitterAPI.Controller, :user_timeline
get "/qvitter/statuses/user_timeline", TwitterAPI.Controller, :user_timeline
get "/statuses/show/:id", TwitterAPI.Controller, :fetch_status
get "/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation

View File

@ -215,10 +215,18 @@ def register_user(params) do
end
end
def get_by_id_or_nickname(id_or_nickname) do
if !is_integer(id_or_nickname) && :error == Integer.parse(id_or_nickname) do
Repo.get_by(User, nickname: id_or_nickname)
else
Repo.get(User, id_or_nickname)
end
end
def get_user(user \\ nil, params) do
case params do
%{"user_id" => user_id} ->
case target = Repo.get(User, user_id) do
case target = get_by_id_or_nickname(user_id) do
nil ->
{:error, "No user with such user_id"}
_ ->

View File

@ -1 +1 @@
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>Pleroma</title><link rel=stylesheet href=/static/font/css/fontello.css><link rel=stylesheet href=/static/font/css/animation.css><link href=/static/css/app.3662cf7b10084635d2b09041a8340797.css rel=stylesheet></head><body style="display: none"><div id=app></div><script type=text/javascript src=/static/js/manifest.f77f8e3098770cd89c4f.js></script><script type=text/javascript src=/static/js/vendor.bcbf57bfdffb555a1e28.js></script><script type=text/javascript src=/static/js/app.cb2a631521680466b348.js></script></body></html>
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>Pleroma</title><link rel=stylesheet href=/static/font/css/fontello.css><link rel=stylesheet href=/static/font/css/animation.css><link href=/static/css/app.3662cf7b10084635d2b09041a8340797.css rel=stylesheet></head><body style="display: none"><div id=app></div><script type=text/javascript src=/static/js/manifest.43d2fa23b3a57580d990.js></script><script type=text/javascript src=/static/js/vendor.7b75d360647f8aca9a27.js></script><script type=text/javascript src=/static/js/app.21c841e6c909dfcf6600.js></script></body></html>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -133,6 +133,7 @@ test "get a user by params" do
assert {:error, "You need to specify screen_name or user_id"} == TwitterAPI.get_user(nil, nil)
assert user1_result == TwitterAPI.get_user(nil, %{"user_id" => user1.id})
assert user1_result == TwitterAPI.get_user(nil, %{"user_id" => user1.nickname})
assert user1_result == TwitterAPI.get_user(nil, %{"screen_name" => user1.nickname})
assert user1_result == TwitterAPI.get_user(user1, nil)
assert user1_result == TwitterAPI.get_user(user2, %{"user_id" => user1.id})