twitter api: add friend requests list api
authorWilliam Pitcock <nenolod@dereferenced.org>
Tue, 29 May 2018 15:30:06 +0000 (15:30 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Mon, 11 Jun 2018 22:15:53 +0000 (22:15 +0000)
lib/pleroma/web/router.ex
lib/pleroma/web/twitter_api/twitter_api_controller.ex

index b37c8168fde322a86eacd30d7c6bef3bbc33ea2f..ea134bbff2c3e545fe3dd39b9c2b6d662ac42326 100644 (file)
@@ -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)
index b078c447efbf18b5b7b65a84a4d139b2823cee77..123d201771604b1856f75563317eef65fa15644a 100644 (file)
@@ -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 =