From 435bf1f9450954eab5f753a983dee202aa11bac1 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Wed, 11 Nov 2020 20:12:35 +0400 Subject: [PATCH] Remove FrontendInstallerWorker --- config/config.exs | 2 -- .../controllers/frontend_controller.ex | 3 +-- .../workers/frontend_installer_worker.ex | 21 ------------------ .../controllers/frontend_controller_test.exs | 22 ------------------- 4 files changed, 1 insertion(+), 47 deletions(-) delete mode 100644 lib/pleroma/workers/frontend_installer_worker.ex diff --git a/config/config.exs b/config/config.exs index 1d09a0238..0b8a75aad 100644 --- a/config/config.exs +++ b/config/config.exs @@ -563,9 +563,7 @@ config :pleroma, Oban, remote_fetcher: 2, attachments_cleanup: 5, new_users_digest: 1, - frontend_installer: 1, mute_expire: 5 - ], plugins: [Oban.Plugins.Pruner], crontab: [ diff --git a/lib/pleroma/web/admin_api/controllers/frontend_controller.ex b/lib/pleroma/web/admin_api/controllers/frontend_controller.ex index 59c69aba1..4518bed5a 100644 --- a/lib/pleroma/web/admin_api/controllers/frontend_controller.ex +++ b/lib/pleroma/web/admin_api/controllers/frontend_controller.ex @@ -7,7 +7,6 @@ defmodule Pleroma.Web.AdminAPI.FrontendController do alias Pleroma.Config alias Pleroma.Web.Plugs.OAuthScopesPlug - alias Pleroma.Workers.FrontendInstallerWorker plug(Pleroma.Web.ApiSpec.CastAndValidate) plug(OAuthScopesPlug, %{scopes: ["write"], admin: true} when action == :install) @@ -30,7 +29,7 @@ defmodule Pleroma.Web.AdminAPI.FrontendController do end def install(%{body_params: params} = conn, _params) do - FrontendInstallerWorker.install(params.name, Map.delete(params, :name)) + Pleroma.Frontend.install(params.name, Map.delete(params, :name)) index(conn, %{}) end diff --git a/lib/pleroma/workers/frontend_installer_worker.ex b/lib/pleroma/workers/frontend_installer_worker.ex deleted file mode 100644 index 38688c63b..000000000 --- a/lib/pleroma/workers/frontend_installer_worker.ex +++ /dev/null @@ -1,21 +0,0 @@ -# Pleroma: A lightweight social networking server -# Copyright © 2017-2020 Pleroma Authors -# SPDX-License-Identifier: AGPL-3.0-only - -defmodule Pleroma.Workers.FrontendInstallerWorker do - use Oban.Worker, queue: :frontend_installer, max_attempts: 1 - - alias Oban.Job - alias Pleroma.Frontend - - def install(name, opts \\ []) do - %{"name" => name, "opts" => Map.new(opts)} - |> new() - |> Oban.insert() - end - - def perform(%Job{args: %{"name" => name, "opts" => opts}}) do - opts = Keyword.new(opts, fn {key, value} -> {String.to_existing_atom(key), value} end) - Frontend.install(name, opts) - end -end diff --git a/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs b/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs index afe82ddf5..1d4fbfa03 100644 --- a/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs +++ b/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs @@ -4,13 +4,10 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do use Pleroma.Web.ConnCase - use Oban.Testing, repo: Pleroma.Repo import Pleroma.Factory alias Pleroma.Config - alias Pleroma.Tests.ObanHelpers - alias Pleroma.Workers.FrontendInstallerWorker @dir "test/frontend_static_test" @@ -66,13 +63,6 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do |> post("/api/pleroma/admin/frontends", %{name: "pleroma"}) |> json_response_and_validate_schema(:ok) - assert_enqueued( - worker: FrontendInstallerWorker, - args: %{"name" => "pleroma", "opts" => %{}} - ) - - ObanHelpers.perform(all_enqueued(worker: FrontendInstallerWorker)) - assert File.exists?(Path.join([@dir, "frontends", "pleroma", "fantasy", "test.txt"])) response = @@ -108,16 +98,6 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do }) |> json_response_and_validate_schema(:ok) - assert_enqueued( - worker: FrontendInstallerWorker, - args: %{ - "name" => "pleroma", - "opts" => %{"file" => "test/fixtures/tesla_mock/frontend.zip"} - } - ) - - ObanHelpers.perform(all_enqueued(worker: FrontendInstallerWorker)) - assert File.exists?(Path.join([@dir, "frontends", "pleroma", "fantasy", "test.txt"])) end @@ -136,8 +116,6 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do }) |> json_response_and_validate_schema(:ok) - ObanHelpers.perform(all_enqueued(worker: FrontendInstallerWorker)) - assert File.exists?(Path.join([@dir, "frontends", "unknown", "baka", "test.txt"])) end end