Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into develop
[akkoma] / lib / pleroma / web / mastodon_api / controllers / mastodon_api_controller.ex
index a66335c0227f841499703d12c03dcc59986ccce2..e92f5d08935424f56826e280fa5fd5e601a944b4 100644 (file)
@@ -8,13 +8,11 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
   import Pleroma.Web.ControllerHelper, only: [add_link_headers: 2]
 
   alias Pleroma.Bookmark
-  alias Pleroma.Config
   alias Pleroma.Pagination
   alias Pleroma.User
   alias Pleroma.Web.ActivityPub.ActivityPub
   alias Pleroma.Web.CommonAPI
   alias Pleroma.Web.MastodonAPI.AccountView
-  alias Pleroma.Web.MastodonAPI.MastodonView
   alias Pleroma.Web.MastodonAPI.StatusView
 
   require Logger
@@ -87,124 +85,6 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
     |> render("index.json", %{activities: activities, for: user, as: :activity})
   end
 
-  def index(%{assigns: %{user: user}} = conn, _params) do
-    token = get_session(conn, :oauth_token)
-
-    if user && token do
-      mastodon_emoji =
-        Pleroma.Web.MastodonAPI.CustomEmojiView.render("index.json", %{
-          custom_emojis: Pleroma.Emoji.get_all()
-        })
-
-      limit = Config.get([:instance, :limit])
-
-      accounts = Map.put(%{}, user.id, AccountView.render("show.json", %{user: user, for: user}))
-
-      initial_state =
-        %{
-          meta: %{
-            streaming_api_base_url: Pleroma.Web.Endpoint.websocket_url(),
-            access_token: token,
-            locale: "en",
-            domain: Pleroma.Web.Endpoint.host(),
-            admin: "1",
-            me: "#{user.id}",
-            unfollow_modal: false,
-            boost_modal: false,
-            delete_modal: true,
-            auto_play_gif: false,
-            display_sensitive_media: false,
-            reduce_motion: false,
-            max_toot_chars: limit,
-            mascot: User.get_mascot(user)["url"]
-          },
-          poll_limits: Config.get([:instance, :poll_limits]),
-          rights: %{
-            delete_others_notice: present?(user.info.is_moderator),
-            admin: present?(user.info.is_admin)
-          },
-          compose: %{
-            me: "#{user.id}",
-            default_privacy: user.info.default_scope,
-            default_sensitive: false,
-            allow_content_types: Config.get([:instance, :allowed_post_formats])
-          },
-          media_attachments: %{
-            accept_content_types: [
-              ".jpg",
-              ".jpeg",
-              ".png",
-              ".gif",
-              ".webm",
-              ".mp4",
-              ".m4v",
-              "image\/jpeg",
-              "image\/png",
-              "image\/gif",
-              "video\/webm",
-              "video\/mp4"
-            ]
-          },
-          settings:
-            user.info.settings ||
-              %{
-                onboarded: true,
-                home: %{
-                  shows: %{
-                    reblog: true,
-                    reply: true
-                  }
-                },
-                notifications: %{
-                  alerts: %{
-                    follow: true,
-                    favourite: true,
-                    reblog: true,
-                    mention: true
-                  },
-                  shows: %{
-                    follow: true,
-                    favourite: true,
-                    reblog: true,
-                    mention: true
-                  },
-                  sounds: %{
-                    follow: true,
-                    favourite: true,
-                    reblog: true,
-                    mention: true
-                  }
-                }
-              },
-          push_subscription: nil,
-          accounts: accounts,
-          custom_emojis: mastodon_emoji,
-          char_limit: limit
-        }
-        |> Jason.encode!()
-
-      conn
-      |> put_layout(false)
-      |> put_view(MastodonView)
-      |> render("index.html", %{initial_state: initial_state})
-    else
-      conn
-      |> put_session(:return_to, conn.request_path)
-      |> redirect(to: "/web/login")
-    end
-  end
-
-  def put_settings(%{assigns: %{user: user}} = conn, %{"data" => settings} = _params) do
-    with {:ok, _} <- User.update_info(user, &User.Info.mastodon_settings_update(&1, settings)) do
-      json(conn, %{})
-    else
-      e ->
-        conn
-        |> put_status(:internal_server_error)
-        |> json(%{error: inspect(e)})
-    end
-  end
-
   # Stubs for unimplemented mastodon api
   #
   def empty_array(conn, _) do
@@ -216,8 +96,4 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
     Logger.debug("Unimplemented, returning an empty object")
     json(conn, %{})
   end
-
-  defp present?(nil), do: false
-  defp present?(false), do: false
-  defp present?(_), do: true
 end