/api/v1/accounts/relationships Return an empty array if no id in params
[akkoma] / lib / pleroma / web / mastodon_api / mastodon_api_controller.ex
index 51a7ec2b24aef3c5b041f364169baaa47e846912..af4cf2b712736dd0d1dcafe7561c2e28e591589d 100644 (file)
@@ -443,6 +443,12 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
     render(conn, AccountView, "relationships.json", %{user: user, targets: targets})
   end
 
+  # Instead of returning a 400 when no "id" params is present, Mastodon returns an empty array.
+  def relationships(%{assigns: %{user: user}} = conn, _) do
+    conn
+    |> json([])
+  end
+
   def update_media(%{assigns: %{user: _}} = conn, data) do
     with %Object{} = object <- Repo.get(Object, data["id"]),
          true <- is_binary(data["description"]),
@@ -989,7 +995,6 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
     with {:ok, app} <- get_or_make_app(),
          %Authorization{} = auth <- Repo.get_by(Authorization, token: code, app_id: app.id),
          {:ok, token} <- Token.exchange_token(app, auth) do
-
       conn
       |> put_session(:oauth_token, token.token)
       |> redirect(to: "/web/getting-started")