diff --git a/services/app/apps/codebattle/lib/codebattle_web/channels/main_channel.ex b/services/app/apps/codebattle/lib/codebattle_web/channels/main_channel.ex index 4bf782cef..d11ef95d2 100644 --- a/services/app/apps/codebattle/lib/codebattle_web/channels/main_channel.ex +++ b/services/app/apps/codebattle/lib/codebattle_web/channels/main_channel.ex @@ -4,13 +4,18 @@ defmodule CodebattleWeb.MainChannel do alias CodebattleWeb.Presence + @use_presence Application.compile_env(:codebattle, CodebattleWeb.MainChannel)[:use_presence] + def join("main", %{"state" => state}, socket) do current_user = socket.assigns.current_user if !current_user.is_guest do topic = "main:#{current_user.id}" Codebattle.PubSub.subscribe(topic) - send(self(), {:after_join, state}) + + if @use_presence do + send(self(), {:after_join, state}) + end end {:ok, %{}, socket} diff --git a/services/app/config/dev.exs b/services/app/config/dev.exs index 00258dc20..a422067e9 100644 --- a/services/app/config/dev.exs +++ b/services/app/config/dev.exs @@ -55,3 +55,5 @@ config :codebattle, Codebattle.Plugs, rollbar_api_key: System.get_env("ROLLBAR_A config :codebattle, Codebattle.Invite, timeout: :timer.minutes(15), lifetime: :timer.minutes(15) + +config :codebattle, CodebattleWeb.MainChannel, use_presence: true diff --git a/services/app/config/prod.exs b/services/app/config/prod.exs index 853fcbfce..a813f1f36 100644 --- a/services/app/config/prod.exs +++ b/services/app/config/prod.exs @@ -13,6 +13,7 @@ config :logger, level: :error config :codebattle, Codebattle.Invite, timeout: :timer.minutes(15) config :codebattle, Codebattle.Invite, lifetime: :timer.minutes(15) +config :codebattle, CodebattleWeb.MainChannel, use_presence: false config :codebattle, ws_port: 8080 config :codebattle, restore_tournaments: true diff --git a/services/app/config/test.exs b/services/app/config/test.exs index 83108302c..3f44964b5 100644 --- a/services/app/config/test.exs +++ b/services/app/config/test.exs @@ -56,6 +56,8 @@ config :codebattle, Codebattle.Invite, timeout: :timer.seconds(1000), lifetime: :timer.seconds(0) +config :codebattle, CodebattleWeb.MainChannel, use_presence: false + config :codebattle, tasks_provider: Codebattle.Game.FakeTasksQueuesServer config :codebattle, :firebase,