OStatus: Add user bio as summary field
[akkoma] / lib / pleroma / web / mastodon_api / mastodon_api_controller.ex
index ca1e4c8d5e6d2b0eaaae8f2c7b95d70e5ec22f53..61bf8b4b8ed73aaeceeebb31083c94d4739cf11d 100644 (file)
@@ -93,6 +93,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
   @instance Application.get_env(:pleroma, :instance)
 
   def masto_instance(conn, _params) do
+    user_count = Repo.aggregate(User.local_user_query, :count, :id)
     response = %{
       uri: Web.base_url,
       title: Keyword.get(@instance, :name),
@@ -103,10 +104,11 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
         streaming_api: String.replace(Web.base_url, ["http","https"], "wss")
       },
       stats: %{
-        user_count: 1,
         status_count: 2,
+        user_count: user_count,
         domain_count: 3
-      }
+      },
+      max_toot_chars: Keyword.get(@instance, :limit)
     }
 
     json(conn, response)
@@ -558,7 +560,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
 
   def login(conn, _) do
     conn
-    |> render(MastodonView, "login.html")
+    |> render(MastodonView, "login.html", %{error: false})
   end
 
   defp get_or_make_app() do
@@ -580,9 +582,19 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
       conn
       |> put_session(:oauth_token, token.token)
       |> redirect(to: "/web/getting-started")
+    else
+      _e ->
+        conn
+        |> render(MastodonView, "login.html", %{error: "Wrong username or password"})
     end
   end
 
+  def logout(conn, _) do
+    conn
+    |> clear_session
+    |> redirect(to: "/")
+  end
+
   def relationship_noop(%{assigns: %{user: user}} = conn, %{"id" => id}) do
     Logger.debug("Unimplemented, returning unmodified relationship")
     with %User{} = target <- Repo.get(User, id) do