Various runtime configuration fixes
This commit is contained in:
parent
fbc3f2893a
commit
bcecdc3ab1
|
@ -52,6 +52,7 @@
|
||||||
url: [host: "localhost"],
|
url: [host: "localhost"],
|
||||||
protocol: "https",
|
protocol: "https",
|
||||||
secret_key_base: "aK4Abxf29xU9TTDKre9coZPUgevcVCFQJe/5xP/7Lt4BEif6idBIbjupVbOrbKxl",
|
secret_key_base: "aK4Abxf29xU9TTDKre9coZPUgevcVCFQJe/5xP/7Lt4BEif6idBIbjupVbOrbKxl",
|
||||||
|
signing_salt: "CqaoopA2",
|
||||||
render_errors: [view: Pleroma.Web.ErrorView, accepts: ~w(json)],
|
render_errors: [view: Pleroma.Web.ErrorView, accepts: ~w(json)],
|
||||||
pubsub: [name: Pleroma.PubSub, adapter: Phoenix.PubSub.PG2],
|
pubsub: [name: Pleroma.PubSub, adapter: Phoenix.PubSub.PG2],
|
||||||
secure_cookie_flag: true
|
secure_cookie_flag: true
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
# manifest is generated by the mix phoenix.digest task
|
# manifest is generated by the mix phoenix.digest task
|
||||||
# which you typically run after static files are built.
|
# which you typically run after static files are built.
|
||||||
config :pleroma, Pleroma.Web.Endpoint,
|
config :pleroma, Pleroma.Web.Endpoint,
|
||||||
|
server: true,
|
||||||
http: [port: 4000],
|
http: [port: 4000],
|
||||||
protocol: "http"
|
protocol: "http"
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ defmodule Pleroma.Application do
|
||||||
|
|
||||||
# See http://elixir-lang.org/docs/stable/elixir/Application.html
|
# See http://elixir-lang.org/docs/stable/elixir/Application.html
|
||||||
# for more information on OTP Applications
|
# for more information on OTP Applications
|
||||||
|
@env Mix.env()
|
||||||
def start(_type, _args) do
|
def start(_type, _args) do
|
||||||
import Supervisor.Spec
|
import Supervisor.Spec
|
||||||
import Cachex.Spec
|
import Cachex.Spec
|
||||||
|
@ -60,7 +61,7 @@ def start(_type, _args) do
|
||||||
worker(Pleroma.Stats, []),
|
worker(Pleroma.Stats, []),
|
||||||
worker(Pleroma.Gopher.Server, [])
|
worker(Pleroma.Gopher.Server, [])
|
||||||
] ++
|
] ++
|
||||||
if Mix.env() == :test,
|
if @env == :test,
|
||||||
do: [],
|
do: [],
|
||||||
else:
|
else:
|
||||||
[worker(Pleroma.Web.Streamer, [])] ++
|
[worker(Pleroma.Web.Streamer, [])] ++
|
||||||
|
|
|
@ -31,10 +31,12 @@ def normalize(obj) when is_map(obj), do: Object.get_by_ap_id(obj["id"])
|
||||||
def normalize(ap_id) when is_binary(ap_id), do: Object.get_by_ap_id(ap_id)
|
def normalize(ap_id) when is_binary(ap_id), do: Object.get_by_ap_id(ap_id)
|
||||||
def normalize(_), do: nil
|
def normalize(_), do: nil
|
||||||
|
|
||||||
def get_cached_by_ap_id(ap_id) do
|
if Mix.env() == :test do
|
||||||
if Mix.env() == :test do
|
def get_cached_by_ap_id(ap_id) do
|
||||||
get_by_ap_id(ap_id)
|
get_by_ap_id(ap_id)
|
||||||
else
|
end
|
||||||
|
else
|
||||||
|
def get_cached_by_ap_id(ap_id) do
|
||||||
key = "object:#{ap_id}"
|
key = "object:#{ap_id}"
|
||||||
|
|
||||||
Cachex.fetch!(:object_cache, key, fn _ ->
|
Cachex.fetch!(:object_cache, key, fn _ ->
|
||||||
|
|
|
@ -4,9 +4,7 @@ defmodule Pleroma.Web.UserSocket do
|
||||||
|
|
||||||
## Channels
|
## Channels
|
||||||
# channel "room:*", Pleroma.Web.RoomChannel
|
# channel "room:*", Pleroma.Web.RoomChannel
|
||||||
if Application.get_env(:pleroma, :chat) |> Keyword.get(:enabled) do
|
channel("chat:*", Pleroma.Web.ChatChannel)
|
||||||
channel("chat:*", Pleroma.Web.ChatChannel)
|
|
||||||
end
|
|
||||||
|
|
||||||
## Transports
|
## Transports
|
||||||
transport(:websocket, Phoenix.Transports.WebSocket)
|
transport(:websocket, Phoenix.Transports.WebSocket)
|
||||||
|
@ -24,7 +22,8 @@ defmodule Pleroma.Web.UserSocket do
|
||||||
# See `Phoenix.Token` documentation for examples in
|
# See `Phoenix.Token` documentation for examples in
|
||||||
# performing token verification on connect.
|
# performing token verification on connect.
|
||||||
def connect(%{"token" => token}, socket) do
|
def connect(%{"token" => token}, socket) do
|
||||||
with {:ok, user_id} <- Phoenix.Token.verify(socket, "user socket", token, max_age: 84600),
|
with true <- Pleroma.Config.get([:chat, :enabled]),
|
||||||
|
{:ok, user_id} <- Phoenix.Token.verify(socket, "user socket", token, max_age: 84600),
|
||||||
%User{} = user <- Pleroma.Repo.get(User, user_id) do
|
%User{} = user <- Pleroma.Repo.get(User, user_id) do
|
||||||
{:ok, assign(socket, :user_name, user.nickname)}
|
{:ok, assign(socket, :user_name, user.nickname)}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
defmodule Pleroma.Web.Endpoint do
|
defmodule Pleroma.Web.Endpoint do
|
||||||
use Phoenix.Endpoint, otp_app: :pleroma
|
use Phoenix.Endpoint, otp_app: :pleroma
|
||||||
|
|
||||||
if Application.get_env(:pleroma, :chat) |> Keyword.get(:enabled) do
|
socket("/socket", Pleroma.Web.UserSocket)
|
||||||
socket("/socket", Pleroma.Web.UserSocket)
|
|
||||||
end
|
|
||||||
|
|
||||||
socket("/api/v1", Pleroma.Web.MastodonAPI.MastodonSocket)
|
socket("/api/v1", Pleroma.Web.MastodonAPI.MastodonSocket)
|
||||||
|
|
||||||
|
@ -58,7 +56,7 @@ defmodule Pleroma.Web.Endpoint do
|
||||||
Plug.Session,
|
Plug.Session,
|
||||||
store: :cookie,
|
store: :cookie,
|
||||||
key: cookie_name,
|
key: cookie_name,
|
||||||
signing_salt: "CqaoopA2",
|
signing_salt: {Pleroma.Config, :get, [[__MODULE__, :signing_salt], "CqaoopA2"]},
|
||||||
http_only: true,
|
http_only: true,
|
||||||
secure:
|
secure:
|
||||||
Application.get_env(:pleroma, Pleroma.Web.Endpoint) |> Keyword.get(:secure_cookie_flag),
|
Application.get_env(:pleroma, Pleroma.Web.Endpoint) |> Keyword.get(:secure_cookie_flag),
|
||||||
|
|
|
@ -153,11 +153,15 @@ def handle(type, _) do
|
||||||
{:error, "Don't know what to do with this"}
|
{:error, "Don't know what to do with this"}
|
||||||
end
|
end
|
||||||
|
|
||||||
def enqueue(type, payload, priority \\ 1) do
|
if Mix.env() == :test do
|
||||||
if Pleroma.Config.get([:instance, :federating]) do
|
def enqueue(type, payload, priority \\ 1) do
|
||||||
if Mix.env() == :test do
|
if Pleroma.Config.get([:instance, :federating]) do
|
||||||
handle(type, payload)
|
handle(type, payload)
|
||||||
else
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
def enqueue(type, payload, priority \\ 1) do
|
||||||
|
if Pleroma.Config.get([:instance, :federating]) do
|
||||||
GenServer.cast(__MODULE__, {:enqueue, type, payload, priority})
|
GenServer.cast(__MODULE__, {:enqueue, type, payload, priority})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -136,7 +136,7 @@ def notice(conn, %{"id" => id}) do
|
||||||
"html" ->
|
"html" ->
|
||||||
conn
|
conn
|
||||||
|> put_resp_content_type("text/html")
|
|> put_resp_content_type("text/html")
|
||||||
|> send_file(200, "priv/static/index.html")
|
|> send_file(200, Application.app_dir(:pleroma, "priv/static/index.html"))
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
represent_activity(conn, format, activity, user)
|
represent_activity(conn, format, activity, user)
|
||||||
|
|
|
@ -404,11 +404,9 @@ defmodule Fallback.RedirectController do
|
||||||
use Pleroma.Web, :controller
|
use Pleroma.Web, :controller
|
||||||
|
|
||||||
def redirector(conn, _params) do
|
def redirector(conn, _params) do
|
||||||
if Mix.env() != :test do
|
conn
|
||||||
conn
|
|> put_resp_content_type("text/html")
|
||||||
|> put_resp_content_type("text/html")
|
|> send_file(200, Application.app_dir(:pleroma, "priv/static/index.html"))
|
||||||
|> send_file(200, "priv/static/index.html")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def registration_page(conn, params) do
|
def registration_page(conn, params) do
|
||||||
|
|
Loading…
Reference in a new issue