Feature/826 healthcheck endpoint
[akkoma] / lib / pleroma / web / twitter_api / controllers / util_controller.ex
index 9441984c7e1de3ba74559385c2a6e214e2b11f7e..197a89966ca9f02a63b946f7f1f978f7a83b0aad 100644 (file)
@@ -286,7 +286,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
     emoji =
       Emoji.get_all()
       |> Enum.map(fn {short_code, path, tags} ->
-        {short_code, %{image_url: path, tags: String.split(tags, ",")}}
+        {short_code, %{image_url: path, tags: tags}}
       end)
       |> Enum.into(%{})
 
@@ -363,4 +363,17 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
   def captcha(conn, _params) do
     json(conn, Pleroma.Captcha.new())
   end
+
+  def healthcheck(conn, _params) do
+    info = Pleroma.Healthcheck.system_info()
+
+    conn =
+      if info.healthy do
+        conn
+      else
+        Plug.Conn.put_status(conn, :service_unavailable)
+      end
+
+    json(conn, info)
+  end
 end