Merge branch 'formatting-fixes' into 'develop'
[akkoma] / lib / pleroma / web / mastodon_api / mastodon_api_controller.ex
index 41fbe55e7c5aa07ed3895110825efadd01ee51cb..e1256c7b642f637176e0d83dafcf5e628c031a0e 100644 (file)
@@ -113,8 +113,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
     json(conn, response)
   end
 
-  def custom_emojis(conn, _params) do
-    mastodon_emoji = Pleroma.Formatter.get_custom_emoji()
+  defp mastodonized_emoji do
+    Pleroma.Formatter.get_custom_emoji()
     |> Enum.map(fn {shortcode, relative_url} ->
       url = to_string URI.merge(Web.base_url(), relative_url)
       %{
@@ -123,6 +123,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
         "url" => url
       }
     end)
+  end
+
+  def custom_emojis(conn, _params) do
+    mastodon_emoji = mastodonized_emoji()
     json conn, mastodon_emoji
   end
 
@@ -223,9 +227,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
   end
 
   def reblog_status(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do
-    with {:ok, _announce, %{data: %{"id" => id}}} = CommonAPI.repeat(ap_id_or_id, user),
-         %Activity{} = activity <- Activity.get_create_activity_by_object_ap_id(id) do
-      render conn, StatusView, "status.json", %{activity: activity, for: user, as: :activity}
+    with {:ok, announce, _activity} = CommonAPI.repeat(ap_id_or_id, user) do
+      render conn, StatusView, "status.json", %{activity: announce, for: user, as: :activity}
     end
   end
 
@@ -474,6 +477,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
     |> get_session(:oauth_token)
 
     if user && token do
+      mastodon_emoji = mastodonized_emoji()
       accounts = Map.put(%{}, user.id, AccountView.render("account.json", %{user: user}))
       initial_state = %{
         meta: %{
@@ -541,7 +545,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
         },
         push_subscription: nil,
         accounts: accounts,
-        custom_emojis: %{}
+        custom_emojis: mastodon_emoji
       } |> Poison.encode!
       conn
       |> put_layout(false)
@@ -575,7 +579,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
          {:ok, token} <- Token.exchange_token(app, auth) do
       conn
       |> put_session(:oauth_token, token.token)
-      |> redirect(to: "/web/timelines/public")
+      |> redirect(to: "/web/getting-started")
     end
   end
 
@@ -591,7 +595,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
     json(conn, [])
   end
 
-  defp render_notification(user, %{id: id, activity: activity, inserted_at: created_at} = _params) do
+  def render_notification(user, %{id: id, activity: activity, inserted_at: created_at} = _params) do
     actor = User.get_cached_by_ap_id(activity.data["actor"])
     created_at = NaiveDateTime.to_iso8601(created_at)
     |> String.replace(~r/(\.\d+)?$/, ".000Z", global: false)