twitter api: add friend requests list api
This commit is contained in:
parent
ba8dab7542
commit
e08cf21e5b
|
@ -247,6 +247,8 @@ def user_fetcher(username) do
|
||||||
post("/statuses/retweet/:id", TwitterAPI.Controller, :retweet)
|
post("/statuses/retweet/:id", TwitterAPI.Controller, :retweet)
|
||||||
post("/statuses/destroy/:id", TwitterAPI.Controller, :delete_post)
|
post("/statuses/destroy/:id", TwitterAPI.Controller, :delete_post)
|
||||||
|
|
||||||
|
get("/pleroma/friend_requests", TwitterAPI.Controller, :friend_requests)
|
||||||
|
|
||||||
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("/blocks/create", TwitterAPI.Controller, :block)
|
post("/blocks/create", TwitterAPI.Controller, :block)
|
||||||
|
|
|
@ -331,6 +331,15 @@ def friends(conn, params) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def friend_requests(conn, params) do
|
||||||
|
with {:ok, user} <- TwitterAPI.get_user(conn.assigns.user, params),
|
||||||
|
{:ok, friend_requests} <- User.get_follow_requests(user) do
|
||||||
|
render(conn, UserView, "index.json", %{users: friend_requests, for: user})
|
||||||
|
else
|
||||||
|
_e -> bad_request_reply(conn, "Can't get friend requests")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def friends_ids(%{assigns: %{user: user}} = conn, _params) do
|
def friends_ids(%{assigns: %{user: user}} = conn, _params) do
|
||||||
with {:ok, friends} <- User.get_friends(user) do
|
with {:ok, friends} <- User.get_friends(user) do
|
||||||
ids =
|
ids =
|
||||||
|
|
Loading…
Reference in a new issue