Add an API endpoint to install a new frontend
[akkoma] / lib / pleroma / workers / frontend_installer_worker.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Workers.FrontendInstallerWorker do
6 use Oban.Worker, queue: :frontend_installer, max_attempts: 1
7
8 alias Oban.Job
9 alias Pleroma.Frontend
10
11 def install(name, opts \\ []) do
12 %{"name" => name, "opts" => Map.new(opts)}
13 |> new()
14 |> Oban.insert()
15 end
16
17 def perform(%Job{args: %{"name" => name, "opts" => opts}}) do
18 opts = Keyword.new(opts, fn {key, value} -> {String.to_existing_atom(key), value} end)
19 Frontend.install(name, opts)
20 end
21 end