diff options
author | eal <eal@waifu.club> | 2018-02-01 19:23:26 +0200 |
---|---|---|
committer | eal <eal@waifu.club> | 2018-02-03 13:42:37 +0200 |
commit | f0745148a3126e3bc621170791a55713e929c682 (patch) | |
tree | d94175057d1a0cdd91e8077e1bbff54a628f5808 /lib | |
parent | 15cb3f2b01dfd914fa414174602ad03b41dfa768 (diff) | |
download | pleroma-f0745148a3126e3bc621170791a55713e929c682.tar.gz |
Add config option for enabling/disabling chat.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/application.ex | 6 | ||||
-rw-r--r-- | lib/pleroma/web/channels/user_socket.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/endpoint.ex | 4 |
3 files changed, 11 insertions, 3 deletions
diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index cdfca8b1a..79b9dee9d 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -20,14 +20,18 @@ defmodule Pleroma.Application do limit: 2500 ]]), worker(Pleroma.Web.Federator, []), - worker(Pleroma.Web.ChatChannel.ChatChannelState, []), worker(Pleroma.Stats, []), ] ++ 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 # for other strategies and supported options opts = [strategy: :one_for_one, name: Pleroma.Supervisor] Supervisor.start_link(children, opts) end + + defp chat_enabled do + Application.get_env(:pleroma, :chat, []) |> Keyword.get(:enabled) + end end diff --git a/lib/pleroma/web/channels/user_socket.ex b/lib/pleroma/web/channels/user_socket.ex index 4a9bb8e22..f18b3cb80 100644 --- a/lib/pleroma/web/channels/user_socket.ex +++ b/lib/pleroma/web/channels/user_socket.ex @@ -5,7 +5,9 @@ defmodule Pleroma.Web.UserSocket do ## Channels # 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 transport :websocket, Phoenix.Transports.WebSocket diff --git a/lib/pleroma/web/endpoint.ex b/lib/pleroma/web/endpoint.ex index 725d2ee64..8b09199e0 100644 --- a/lib/pleroma/web/endpoint.ex +++ b/lib/pleroma/web/endpoint.ex @@ -1,7 +1,9 @@ defmodule Pleroma.Web.Endpoint do 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 # Serve at "/" the static files from "priv/static" directory. |