[
:user_cache,
[
- default_ttl: 25000,
+ default_ttl: 25_000,
ttl_interval: 1000,
limit: 2500
]
[
:object_cache,
[
- default_ttl: 25000,
+ default_ttl: 25_000,
ttl_interval: 1000,
limit: 2500
]
def needs_update?(%User{local: false, last_refreshed_at: nil}), do: true
def needs_update?(%User{local: false} = user) do
- NaiveDateTime.diff(NaiveDateTime.utc_now(), user.last_refreshed_at) >= 86400
+ NaiveDateTime.diff(NaiveDateTime.utc_now(), user.last_refreshed_at) >= 86_400
end
def needs_update?(_), do: true
# performing token verification on connect.
def connect(%{"token" => token}, socket) do
with true <- Pleroma.Config.get([:chat, :enabled]),
- {:ok, user_id} <- Phoenix.Token.verify(socket, "user socket", token, max_age: 84600),
+ {:ok, user_id} <- Phoenix.Token.verify(socket, "user socket", token, max_age: 84_600),
%User{} = user <- Pleroma.Repo.get(User, user_id) do
{:ok, assign(socket, :user_name, user.nickname)}
else
# Native generation of RSA keys is only available since OTP 20+ and in default build conditions
# We try at compile time to generate natively an RSA key otherwise we fallback on the old way.
try do
- _ = :public_key.generate_key({:rsa, 2048, 65537})
+ _ = :public_key.generate_key({:rsa, 2048, 65_537})
def generate_rsa_pem do
- key = :public_key.generate_key({:rsa, 2048, 65537})
+ key = :public_key.generate_key({:rsa, 2048, 65_537})
entry = :public_key.pem_entry_encode(:RSAPrivateKey, key)
pem = :public_key.pem_encode([entry]) |> String.trim_trailing()
{:ok, pem}