forked from AkkomaGang/akkoma
parent
f9a7b456eb
commit
c4e9c4bc95
7 changed files with 46 additions and 3 deletions
|
@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- extended runtime module support, see config cheatsheet
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Updated mastoFE path, for the newer version
|
- Updated mastoFE path, for the newer version
|
||||||
|
|
||||||
|
@ -18,7 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- `/api/v1/notifications/dismiss`
|
- `/api/v1/notifications/dismiss`
|
||||||
- `/api/v1/search`
|
- `/api/v1/search`
|
||||||
- `/api/v1/statuses/{id}/card`
|
- `/api/v1/statuses/{id}/card`
|
||||||
- LDAP authenticator
|
- LDAP authenticator (use the akkoma-contrib-authenticator-ldap runtime module)
|
||||||
- Chats, they were half-baked. Just use PMs.
|
- Chats, they were half-baked. Just use PMs.
|
||||||
- Prometheus, it causes massive slowdown
|
- Prometheus, it causes massive slowdown
|
||||||
|
|
||||||
|
|
|
@ -1012,7 +1012,22 @@ config :pleroma, Pleroma.Formatter,
|
||||||
|
|
||||||
## Custom Runtime Modules (`:modules`)
|
## Custom Runtime Modules (`:modules`)
|
||||||
|
|
||||||
* `runtime_dir`: A path to custom Elixir modules (such as MRF policies).
|
* `runtime_dir`: A path to custom Elixir modules, such as MRF policies or
|
||||||
|
custom authenticators. These modules will be loaded on boot, and can be
|
||||||
|
contained in subdirectories. It is advised to use version-controlled
|
||||||
|
subdirectories to make management of them a bit easier. Note that only
|
||||||
|
files with the extension `.ex` will be loaded.
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
config :pleroma, :modules, runtime_dir: "instance/modules"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Adding a module
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd instance/modules/
|
||||||
|
git clone <MY MODULE>
|
||||||
|
```
|
||||||
|
|
||||||
## :configurable_from_database
|
## :configurable_from_database
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,23 @@ defmodule Pleroma.Utils do
|
||||||
@repo_timeout Pleroma.Config.get([Pleroma.Repo, :timeout], 15_000)
|
@repo_timeout Pleroma.Config.get([Pleroma.Repo, :timeout], 15_000)
|
||||||
|
|
||||||
def compile_dir(dir) when is_binary(dir) do
|
def compile_dir(dir) when is_binary(dir) do
|
||||||
|
dir
|
||||||
|
|> elixir_files()
|
||||||
|
|> Kernel.ParallelCompiler.compile()
|
||||||
|
end
|
||||||
|
|
||||||
|
defp elixir_files(dir) when is_binary(dir) do
|
||||||
dir
|
dir
|
||||||
|> File.ls!()
|
|> File.ls!()
|
||||||
|> Enum.map(&Path.join(dir, &1))
|
|> Enum.map(&Path.join(dir, &1))
|
||||||
|> Kernel.ParallelCompiler.compile()
|
|> Enum.flat_map(fn path ->
|
||||||
|
if File.dir?(path) do
|
||||||
|
elixir_files(path)
|
||||||
|
else
|
||||||
|
[path]
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|> Enum.filter(fn path -> String.ends_with?(path, ".ex") end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
|
2
test/fixtures/runtime_modules/first.ex
vendored
Normal file
2
test/fixtures/runtime_modules/first.ex
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
defmodule DynamicModule.First do
|
||||||
|
end
|
1
test/fixtures/runtime_modules/nope.exs
vendored
Normal file
1
test/fixtures/runtime_modules/nope.exs
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
def thisisnotloaded
|
2
test/fixtures/runtime_modules/subdir/second.ex
vendored
Normal file
2
test/fixtures/runtime_modules/subdir/second.ex
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
defmodule DynamicModule.Second do
|
||||||
|
end
|
|
@ -12,4 +12,11 @@ test "returns unique temporary directory" do
|
||||||
File.rm_rf(path)
|
File.rm_rf(path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "compile_dir/1" do
|
||||||
|
test "recursively compiles directories" do
|
||||||
|
{:ok, [DynamicModule.First, DynamicModule.Second], []} =
|
||||||
|
Pleroma.Utils.compile_dir("test/fixtures/runtime_modules")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue