@repository Mix.Project.config()[:source_url]
def name, do: @name
def version, do: @version
- def named_version(), do: @name <> " " <> @version
+ def named_version, do: @name <> " " <> @version
def repository, do: @repository
- def user_agent() do
+ def user_agent do
info = "#{Pleroma.Web.base_url()} <#{Pleroma.Config.get([:instance, :email], "")}>"
named_version() <> "; " <> info
end
Supervisor.start_link(children, opts)
end
- def enabled_hackney_pools() do
+ def enabled_hackney_pools do
[:media] ++
if Application.get_env(:tesla, :adapter) == Tesla.Adapter.Hackney do
[:federation]
end
if Mix.env() == :test do
- defp streamer_child(), do: []
- defp chat_child(), do: []
+ defp streamer_child, do: []
+ defp chat_child, do: []
else
- defp streamer_child() do
+ defp streamer_child do
[worker(Pleroma.Web.Streamer, [])]
end
- defp chat_child() do
+ defp chat_child do
if Pleroma.Config.get([:chat, :enabled]) do
[worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
else
end
end
- defp hackney_pool_children() do
+ defp hackney_pool_children do
for pool <- enabled_hackney_pools() do
options = Pleroma.Config.get([:hackney_pools, pool])
:hackney_pool.child_spec(pool, options)
use GenServer
@doc false
- def start_link() do
+ def start_link do
GenServer.start_link(__MODULE__, [], name: __MODULE__)
end
@doc """
Ask the configured captcha service for a new captcha
"""
- def new() do
+ def new do
GenServer.call(__MODULE__, :new)
end
@behaviour Service
@impl Service
- def new() do
+ def new do
endpoint = Pleroma.Config.get!([__MODULE__, :endpoint])
case Tesla.get(endpoint <> "/new") do
# No software is complete until they have a Clippy implementation.
# A ballmer peak _may_ be required to change this module.
- def tip() do
+ def tip do
tips()
|> Enum.random()
|> puts()
end
- def tips() do
+ def tips do
host = Pleroma.Config.get([Pleroma.Web.Endpoint, :url, :host])
[
defmodule Pleroma.Config.DeprecationWarnings do
require Logger
- def check_frontend_config_mechanism() do
+ def check_frontend_config_mechanism do
if Pleroma.Config.get(:fe) do
Logger.warn("""
!!!DEPRECATION WARNING!!!
@ets_options [:ordered_set, :protected, :named_table, {:read_concurrency, true}]
@doc false
- def start_link() do
+ def start_link do
GenServer.start_link(__MODULE__, [], name: __MODULE__)
end
@doc "Reloads the emojis from disk."
@spec reload() :: :ok
- def reload() do
+ def reload do
GenServer.call(__MODULE__, :reload)
end
@doc "Returns all the emojos!!"
@spec get_all() :: [{String.t(), String.t()}, ...]
- def get_all() do
+ def get_all do
:ets.tab2list(@ets)
end
{:ok, state}
end
- defp load() do
+ defp load do
emojis =
(load_finmoji(Keyword.get(Application.get_env(:pleroma, :instance), :finmoji_enabled)) ++
load_from_file("config/emoji.txt") ++
{:ok, FlakeId.from_string(value)}
end
- def autogenerate(), do: get()
+ def autogenerate, do: get()
# -- GenServer API
def start_link do
1_000_000_000 * mega_seconds + seconds * 1000 + :erlang.trunc(micro_seconds / 1000)
end
- defp worker_id() do
+ defp worker_id do
<<worker::integer-size(48)>> = :crypto.strong_rand_bytes(6)
worker
end
use GenServer
require Logger
- def start_link() do
+ def start_link do
config = Pleroma.Config.get(:gopher, [])
ip = Keyword.get(config, :ip, {0, 0, 0, 0})
port = Keyword.get(config, :port, 1234)
defp get_scrubbers(scrubbers) when is_list(scrubbers), do: scrubbers
defp get_scrubbers(_), do: [Pleroma.HTML.Scrubber.Default]
- def get_scrubbers() do
+ def get_scrubbers do
Pleroma.Config.get([:markup, :scrub_policy])
|> get_scrubbers
end
|> Poison.decode!()
end
- def get_token() do
+ def get_token do
settings = Pleroma.Config.get(Pleroma.Uploaders.Swift)
username = Keyword.fetch!(settings, :username)
password = Keyword.fetch!(settings, :password)
|> Enum.map(&String.downcase(&1))
end
- defp local_nickname_regex() do
+ defp local_nickname_regex do
if Pleroma.Config.get([:instance, :extended_nickname_format]) do
@extended_local_nickname_regex
else
end
end
- defp welcome_user() do
+ defp welcome_user do
with nickname when is_binary(nickname) <-
Pleroma.Config.get([:instance, :welcome_user_nickname]),
%User{local: true} = user <- User.get_cached_by_nickname(nickname) do
end
end
- defp welcome_message() do
+ defp welcome_message do
Pleroma.Config.get([:instance, :welcome_message])
end
end
end)
end
- def get_policies() do
+ def get_policies do
Application.get_env(:pleroma, :instance, [])
|> Keyword.get(:rewrite_policy, [])
|> get_policies()
end)
end
- def messages() do
+ def messages do
Agent.get(__MODULE__, fn state -> state[:messages] |> Enum.reverse() end)
end
end
@websub Application.get_env(:pleroma, :websub)
@ostatus Application.get_env(:pleroma, :ostatus)
- def init() do
+ def init do
# 1 minute
Process.sleep(1000 * 60)
refresh_subscriptions()
Jobs.enqueue(:federator_outgoing, __MODULE__, [:request_subscription, sub])
end
- def refresh_subscriptions() do
+ def refresh_subscriptions do
Jobs.enqueue(:federator_outgoing, __MODULE__, [:refresh_subscriptions])
end
{:ok, %{args | queue_table: queue_table, running_jobs: :sets.new()}}
end
- def start_link() do
+ def start_link do
enabled =
if Mix.env() == :test, do: true, else: Pleroma.Config.get([__MODULE__, :enabled], false)
GenServer.cast(__MODULE__, {:maybe_enqueue, data, transport, retries + 1})
end
- def get_stats() do
+ def get_stats do
GenServer.call(__MODULE__, :get_stats)
end
- def reset_stats() do
+ def reset_stats do
GenServer.call(__MODULE__, :reset_stats)
end
end
end
- def get_retry_timer_interval() do
+ def get_retry_timer_interval do
Pleroma.Config.get([:retry_queue, :interval], 1000)
end
end
end
- defp maybe_kickoff_timer() do
+ defp maybe_kickoff_timer do
GenServer.cast(__MODULE__, :kickoff_timer)
end
end
end
end
- defp get_or_make_app() do
+ defp get_or_make_app do
find_attrs = %{client_name: @local_mastodon_name, redirect_uris: "."}
scopes = ["read", "write", "follow", "push"]
# Client API #
##############
- def start_link() do
+ def start_link do
GenServer.start_link(__MODULE__, :ok, name: __MODULE__)
end
- def vapid_config() do
+ def vapid_config do
Application.get_env(:web_push_encryption, :vapid_details, [])
end
- def enabled() do
+ def enabled do
case vapid_config() do
[] -> false
list when is_list(list) -> true
@behaviour Service
@impl Service
- def new(), do: %{type: :mock}
+ def new, do: %{type: :mock}
@impl Service
def validate(_token, _captcha, _data), do: :ok