Add config option for enabling/disabling chat.

This commit is contained in:
eal 2018-02-01 19:23:26 +02:00
parent 15cb3f2b01
commit f0745148a3
4 changed files with 14 additions and 3 deletions

View file

@ -56,6 +56,9 @@ config :pleroma, :media_proxy,
redirect_on_failure: true redirect_on_failure: true
#base_url: "https://cache.pleroma.social" #base_url: "https://cache.pleroma.social"
config :pleroma, :chat,
enabled: true
# Import environment specific config. This must remain at the bottom # Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above. # of this file so it overrides the configuration defined above.
import_config "#{Mix.env}.exs" import_config "#{Mix.env}.exs"

View file

@ -20,14 +20,18 @@ defmodule Pleroma.Application do
limit: 2500 limit: 2500
]]), ]]),
worker(Pleroma.Web.Federator, []), worker(Pleroma.Web.Federator, []),
worker(Pleroma.Web.ChatChannel.ChatChannelState, []),
worker(Pleroma.Stats, []), worker(Pleroma.Stats, []),
] ]
++ if Mix.env == :test, do: [], else: [worker(Pleroma.Web.Streamer, [])] ++ if Mix.env == :test, do: [], else: [worker(Pleroma.Web.Streamer, [])]
++ if !chat_enabled(), do: [], else: [worker(Pleroma.Web.ChatChannel.ChatChannelState, [])]
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options # for other strategies and supported options
opts = [strategy: :one_for_one, name: Pleroma.Supervisor] opts = [strategy: :one_for_one, name: Pleroma.Supervisor]
Supervisor.start_link(children, opts) Supervisor.start_link(children, opts)
end end
defp chat_enabled do
Application.get_env(:pleroma, :chat, []) |> Keyword.get(:enabled)
end
end end

View file

@ -5,7 +5,9 @@ defmodule Pleroma.Web.UserSocket do
## Channels ## Channels
# channel "room:*", Pleroma.Web.RoomChannel # channel "room:*", Pleroma.Web.RoomChannel
channel "chat:*", Pleroma.Web.ChatChannel if Application.get_env(:pleroma, :chat) |> Keyword.get(:enabled) do
channel "chat:*", Pleroma.Web.ChatChannel
end
## Transports ## Transports
transport :websocket, Phoenix.Transports.WebSocket transport :websocket, Phoenix.Transports.WebSocket

View file

@ -1,7 +1,9 @@
defmodule Pleroma.Web.Endpoint do defmodule Pleroma.Web.Endpoint do
use Phoenix.Endpoint, otp_app: :pleroma use Phoenix.Endpoint, otp_app: :pleroma
socket "/socket", Pleroma.Web.UserSocket if Application.get_env(:pleroma, :chat) |> Keyword.get(:enabled) do
socket "/socket", Pleroma.Web.UserSocket
end
socket "/api/v1", Pleroma.Web.MastodonAPI.MastodonSocket socket "/api/v1", Pleroma.Web.MastodonAPI.MastodonSocket
# Serve at "/" the static files from "priv/static" directory. # Serve at "/" the static files from "priv/static" directory.