Merge branch 'fix/config-disable-chat' into 'develop'
[akkoma] / lib / pleroma / web / endpoint.ex
1 defmodule Pleroma.Web.Endpoint do
2 use Phoenix.Endpoint, otp_app: :pleroma
3
4 if Application.get_env(:pleroma, :chat) |> Keyword.get(:enabled) do
5 socket "/socket", Pleroma.Web.UserSocket
6 end
7 socket "/api/v1", Pleroma.Web.MastodonAPI.MastodonSocket
8
9 # Serve at "/" the static files from "priv/static" directory.
10 #
11 # You should set gzip to true if you are running phoenix.digest
12 # when deploying your static files in production.
13 plug Plug.Static,
14 at: "/media", from: "uploads", gzip: false
15 plug Plug.Static,
16 at: "/", from: :pleroma,
17 only: ~w(index.html static finmoji emoji packs sounds images instance sw.js)
18
19 # Code reloading can be explicitly enabled under the
20 # :code_reloader configuration of your endpoint.
21 if code_reloading? do
22 plug Phoenix.CodeReloader
23 end
24
25 plug TrailingFormatPlug
26 plug Plug.RequestId
27 plug Plug.Logger
28
29 plug Plug.Parsers,
30 parsers: [:urlencoded, :multipart, :json],
31 pass: ["*/*"],
32 json_decoder: Poison
33
34 plug Plug.MethodOverride
35 plug Plug.Head
36
37 # The session will be stored in the cookie and signed,
38 # this means its contents can be read but not tampered with.
39 # Set :encryption_salt if you would also like to encrypt it.
40 plug Plug.Session,
41 store: :cookie,
42 key: "_pleroma_key",
43 signing_salt: "CqaoopA2"
44
45 plug Pleroma.Web.Router
46
47 @doc """
48 Dynamically loads configuration from the system environment
49 on startup.
50
51 It receives the endpoint configuration from the config files
52 and must return the updated configuration.
53 """
54 def load_from_system_env(config) do
55 port = System.get_env("PORT") || raise "expected the PORT environment variable to be set"
56 {:ok, Keyword.put(config, :http, [:inet6, port: port])}
57 end
58 end