mastodon api: account view: fetch follow state and use it to populate `requested...
authorWilliam Pitcock <nenolod@dereferenced.org>
Fri, 5 Oct 2018 23:31:49 +0000 (23:31 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Fri, 5 Oct 2018 23:31:49 +0000 (23:31 +0000)
lib/pleroma/web/mastodon_api/views/account_view.ex

index 96795c4200668dcdc98d390a07455703b5ae1b69..d4d8ee2a5f8d584f0070431d546fac96c678627b 100644 (file)
@@ -72,6 +72,9 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
   end
 
   def render("relationship.json", %{user: user, target: target}) do
+    follow_activity = Pleroma.Web.ActivityPub.Utils.fetch_latest_follow(user, target)
+    requested = follow_activity.data["state"] == "pending"
+
     %{
       id: to_string(target.id),
       following: User.following?(user, target),
@@ -79,7 +82,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
       blocking: User.blocks?(user, target),
       muting: false,
       muting_notifications: false,
-      requested: false,
+      requested: requested,
       domain_blocking: false,
       showing_reblogs: false,
       endorsed: false