send notification only from process where player joined and when discord thread id hasn't been created, set prod log level to info for better debugging
This commit is contained in:
parent
f5773f606a
commit
ed0de7e81f
@ -59,7 +59,8 @@ defmodule Chessh.DiscordNotifier do
|
|||||||
%Game{
|
%Game{
|
||||||
status: :continue,
|
status: :continue,
|
||||||
dark_player: %Player{discord_id: dark_player_discord_id},
|
dark_player: %Player{discord_id: dark_player_discord_id},
|
||||||
light_player: %Player{discord_id: light_player_discord_id}
|
light_player: %Player{discord_id: light_player_discord_id},
|
||||||
|
discord_thread_id: nil
|
||||||
} = game ->
|
} = game ->
|
||||||
game = maybe_put_new_thread_on_game(game)
|
game = maybe_put_new_thread_on_game(game)
|
||||||
|
|
||||||
|
@ -155,6 +155,12 @@ defmodule Chessh.SSH.Client.Game do
|
|||||||
|
|
||||||
if status == :ok && maybe_joined_game do
|
if status == :ok && maybe_joined_game do
|
||||||
:syn.publish(:games, {:game, game_id}, :player_joined)
|
:syn.publish(:games, {:game, game_id}, :player_joined)
|
||||||
|
|
||||||
|
GenServer.cast(
|
||||||
|
:discord_notifier,
|
||||||
|
{:schedule_notification, {:player_joined, game_id},
|
||||||
|
Application.get_env(:chessh, DiscordNotifications)[:game_player_joined_notif_delay_ms]}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
binbo_pid = initialize_game(game_id, fen)
|
binbo_pid = initialize_game(game_id, fen)
|
||||||
@ -212,12 +218,6 @@ defmodule Chessh.SSH.Client.Game do
|
|||||||
:player_joined,
|
:player_joined,
|
||||||
%State{client_pid: client_pid, game: %Game{id: game_id}} = state
|
%State{client_pid: client_pid, game: %Game{id: game_id}} = state
|
||||||
) do
|
) do
|
||||||
GenServer.cast(
|
|
||||||
:discord_notifier,
|
|
||||||
{:schedule_notification, {:player_joined, game_id},
|
|
||||||
Application.get_env(:chessh, DiscordNotifications)[:game_player_joined_notif_delay_ms]}
|
|
||||||
)
|
|
||||||
|
|
||||||
game = Repo.get(Game, game_id) |> Repo.preload([:light_player, :dark_player])
|
game = Repo.get(Game, game_id) |> Repo.preload([:light_player, :dark_player])
|
||||||
new_state = %State{state | game: game}
|
new_state = %State{state | game: game}
|
||||||
send(client_pid, {:send_to_ssh, Renderer.render_board_state(new_state)})
|
send(client_pid, {:send_to_ssh, Renderer.render_board_state(new_state)})
|
||||||
|
Loading…
Reference in New Issue
Block a user