media proxy: good enough wip
[akkoma] / lib / pleroma / web / mastodon_api / mastodon_api_controller.ex
index a3587ff4459b4cc7e7c9130f72dc4e3b1077f9ef..82887966c257469d87247f9d8229c7c4f33044ba 100644 (file)
@@ -106,7 +106,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
         user_count: 1,
         status_count: 2,
         domain_count: 3
-      }
+      },
+      max_toot_chars: Keyword.get(@instance, :limit)
     }
 
     json(conn, response)
@@ -196,6 +197,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
     with %Activity{} = activity <- Repo.get(Activity, id),
          activities <- ActivityPub.fetch_activities_for_context(activity.data["object"]["context"], %{"blocking_user" => user}),
          activities <- activities |> Enum.filter(fn (%{id: aid}) -> to_string(aid) != to_string(id) end),
+         activities <- activities |> Enum.filter(fn (%{data: %{"type" => type}}) -> type == "Create" end),
          grouped_activities <- Enum.group_by(activities, fn (%{id: id}) -> id < activity.id end) do
       result = %{
         ancestors: StatusView.render("index.json", for: user, activities: grouped_activities[true] || [], as: :activity) |> Enum.reverse,
@@ -557,7 +559,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
@@ -579,9 +581,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