forked from AkkomaGang/akkoma
Add support for custom modules
This commit is contained in:
parent
7722e5a67a
commit
48ae3c4347
4 changed files with 28 additions and 0 deletions
|
@ -45,6 +45,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Mix task to list all users (`mix pleroma.user list`)
|
||||
- Support for `X-Forwarded-For` and similar HTTP headers which used by reverse proxies to pass a real user IP address to the backend. Must not be enabled unless your instance is behind at least one reverse proxy (such as Nginx, Apache HTTPD or Varnish Cache).
|
||||
- MRF: New module which handles incoming posts based on their age. By default, all incoming posts that are older than 2 days will be unlisted and not shown to their followers.
|
||||
- Support for custom Elixir modules (such as MRF policies)
|
||||
<details>
|
||||
<summary>API Changes</summary>
|
||||
|
||||
|
|
|
@ -249,6 +249,7 @@
|
|||
quarantined_instances: [],
|
||||
managed_config: true,
|
||||
static_dir: "instance/static/",
|
||||
custom_modules_dir: "instance/modules/",
|
||||
allowed_post_formats: [
|
||||
"text/plain",
|
||||
"text/html",
|
||||
|
|
|
@ -68,6 +68,8 @@ You shouldn't edit the base config directly to avoid breakages and merge conflic
|
|||
* `account_field_name_length`: An account field name maximum length (default: `512`).
|
||||
* `account_field_value_length`: An account field value maximum length (default: `2048`).
|
||||
* `external_user_synchronization`: Enabling following/followers counters synchronization for external users.
|
||||
* `custom_modules_dir`: A path to custom Elixir modules (such as MRF policies).
|
||||
|
||||
|
||||
!!! danger
|
||||
This is a Work In Progress, not usable just yet
|
||||
|
|
|
@ -32,6 +32,7 @@ def user_agent do
|
|||
def start(_type, _args) do
|
||||
Pleroma.Config.DeprecationWarnings.warn()
|
||||
setup_instrumenters()
|
||||
load_custom_modules()
|
||||
|
||||
# Define workers and child supervisors to be supervised
|
||||
children =
|
||||
|
@ -67,6 +68,29 @@ def start(_type, _args) do
|
|||
Supervisor.start_link(children, opts)
|
||||
end
|
||||
|
||||
def load_custom_modules() do
|
||||
dir = Pleroma.Config.get([:instance, :custom_modules_dir])
|
||||
|
||||
if dir && File.exists?(dir) do
|
||||
dir
|
||||
|> File.ls!()
|
||||
|> Enum.map(&Path.join(dir, &1))
|
||||
|> Kernel.ParallelCompiler.compile()
|
||||
|> case do
|
||||
{:error, _errors, _warnings} ->
|
||||
raise "Invalid custom modules"
|
||||
|
||||
{:ok, modules, _warnings} ->
|
||||
Enum.each(modules, fn mod ->
|
||||
name = mod |> Atom.to_string() |> String.trim_leading("Elixir.")
|
||||
IO.puts("Custom module loaded: #{name}")
|
||||
end)
|
||||
|
||||
:ok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp setup_instrumenters do
|
||||
require Prometheus.Registry
|
||||
|
||||
|
|
Loading…
Reference in a new issue