Skip to content

Commit

Permalink
add presence flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ReDBrother committed Nov 28, 2023
1 parent c4da67c commit 4638554
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 2 additions & 0 deletions services/app/config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions services/app/config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions services/app/config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4638554

Please sign in to comment.