Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into feature/digest...
[akkoma] / lib / pleroma / web / twitter_api / controllers / util_controller.ex
index 26407aebdca359ff4be0faf07ecd63f8fdc87f65..ed45ca73574fc62b407ff0429f08beb3f88c107f 100644 (file)
@@ -286,18 +286,30 @@ 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: String.split(tags, ",")}}
       end)
+      |> Enum.into(%{})
 
     json(conn, emoji)
   end
 
+  def update_notificaton_settings(%{assigns: %{user: user}} = conn, params) do
+    with {:ok, _} <- User.update_notification_settings(user, params) do
+      json(conn, %{status: "success"})
+    end
+  end
+
   def follow_import(conn, %{"list" => %Plug.Upload{} = listfile}) do
     follow_import(conn, %{"list" => File.read!(listfile.path)})
   end
 
   def follow_import(%{assigns: %{user: follower}} = conn, %{"list" => list}) do
-    with followed_identifiers <- String.split(list),
+    with lines <- String.split(list, "\n"),
+         followed_identifiers <-
+           Enum.map(lines, fn line ->
+             String.split(line, ",") |> List.first()
+           end)
+           |> List.delete("Account address"),
          {:ok, _} = Task.start(fn -> User.follow_import(follower, followed_identifiers) end) do
       json(conn, "job started")
     end