From d1366f8d46959229fdae398fe7920f6894d9d02a Mon Sep 17 00:00:00 2001 From: Syldexia Date: Sat, 19 May 2018 13:35:49 +0100 Subject: [PATCH] Modified deleting an account to run as a task --- lib/pleroma/web/twitter_api/controllers/util_controller.ex | 6 ++---- test/web/twitter_api/twitter_api_controller_test.exs | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/pleroma/web/twitter_api/controllers/util_controller.ex b/lib/pleroma/web/twitter_api/controllers/util_controller.ex index 3f3ddb9e4..23e7408a0 100644 --- a/lib/pleroma/web/twitter_api/controllers/util_controller.ex +++ b/lib/pleroma/web/twitter_api/controllers/util_controller.ex @@ -200,10 +200,8 @@ def follow_import(%{assigns: %{user: user}} = conn, %{"list" => list}) do def delete_account(%{assigns: %{user: user}} = conn, params) do case CommonAPI.Utils.confirm_current_password(user, params) do {:ok, user} -> - case User.delete(user) do - :ok -> json(conn, %{status: "success"}) - :error -> json(conn, %{error: "Unable to delete user."}) - end + Task.start(fn -> User.delete(user) end) + json(conn, %{status: "success"}) {:error, msg} -> json(conn, %{error: msg}) diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index 170dda145..02aba0bc8 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -825,8 +825,6 @@ test "with credentials and valid password", %{conn: conn, user: current_user} do |> post("/api/pleroma/delete_account", %{"password" => "test"}) assert json_response(conn, 200) == %{"status" => "success"} - fetched_user = Repo.get(User, current_user.id) - assert fetched_user.info == %{"deactivated" => true} end end end