in dev, allow dev FE
[akkoma] / lib / pleroma / web / mastodon_api / views / account_view.ex
index cbb57aee663219e475ccaaeeeac48bd4cc97fedf..190d6ebf235bf43d77af55c1ecd1f08195f86552 100644 (file)
@@ -94,12 +94,12 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
 
     followed_by =
       if following_relationships do
-        case FollowingRelationship.find(following_relationships, target, reading_user) do
-          %{state: :follow_accept} -> true
-          _ -> false
-        end
+        target_to_user_following_relation =
+          FollowingRelationship.find(following_relationships, target, reading_user)
+
+        User.get_follow_state(target, reading_user, target_to_user_following_relation)
       else
-        User.following?(target, reading_user)
+        User.get_follow_state(target, reading_user)
       end
 
     subscribing =
@@ -115,7 +115,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
     %{
       id: to_string(target.id),
       following: follow_state == :follow_accept,
-      followed_by: followed_by,
+      followed_by: followed_by == :follow_accept,
       blocking:
         UserRelationship.exists?(
           user_relationships,
@@ -151,6 +151,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
       subscribing: subscribing,
       notifying: subscribing,
       requested: follow_state == :follow_pending,
+      requested_by: followed_by == :follow_pending,
       domain_blocking: User.blocks_domain?(reading_user, target),
       showing_reblogs:
         not UserRelationship.exists?(
@@ -286,7 +287,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
       },
       last_status_at: user.last_status_at,
       akkoma: %{
-        instance: render("instance.json", %{instance: instance})
+        instance: render("instance.json", %{instance: instance}),
+        status_ttl_days: user.status_ttl_days
       },
       # Pleroma extensions
       # Note: it's insecure to output :email but fully-qualified nickname may serve as safe stub
@@ -332,7 +334,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
          %User{id: user_id}
        ) do
     count =
-      User.get_follow_requests(user)
+      user
+      |> User.get_follow_requests()
       |> length()
 
     data