From e08cf21e5b45f263d7f75641f3a91a5329488f82 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Tue, 29 May 2018 15:30:06 +0000 Subject: [PATCH] twitter api: add friend requests list api --- lib/pleroma/web/router.ex | 2 ++ lib/pleroma/web/twitter_api/twitter_api_controller.ex | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index b37c8168f..ea134bbff 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -247,6 +247,8 @@ defmodule Pleroma.Web.Router do post("/statuses/retweet/:id", TwitterAPI.Controller, :retweet) post("/statuses/destroy/:id", TwitterAPI.Controller, :delete_post) + get("/pleroma/friend_requests", TwitterAPI.Controller, :friend_requests) + post("/friendships/create", TwitterAPI.Controller, :follow) post("/friendships/destroy", TwitterAPI.Controller, :unfollow) post("/blocks/create", TwitterAPI.Controller, :block) diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index b078c447e..123d20177 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -331,6 +331,15 @@ defmodule Pleroma.Web.TwitterAPI.Controller do 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 with {:ok, friends} <- User.get_friends(user) do ids = -- 2.45.2