mastodon api: relationship view: better handle no pre-existing follow activity
authorWilliam Pitcock <nenolod@dereferenced.org>
Fri, 5 Oct 2018 23:50:13 +0000 (23:50 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Fri, 5 Oct 2018 23:50:13 +0000 (23:50 +0000)
lib/pleroma/web/mastodon_api/views/account_view.ex

index d4d8ee2a5f8d584f0070431d546fac96c678627b..b68845e16b12ebefa7e8e37ba71d9e35dbae3d96 100644 (file)
@@ -73,7 +73,13 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
 
   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"
+
+    requested =
+      if follow_activity do
+        follow_activity.data["state"] == "pending"
+      else
+        false
+      end
 
     %{
       id: to_string(target.id),