Skip to content

Commit

Permalink
fix: return :ok on successful Presence.track/4 call (#844)
Browse files Browse the repository at this point in the history
* fix: return :ok on successful Presence.track/4 call

* format

---------

Co-authored-by: Filipe Cabaço <filipecabaco@gmail.com>
  • Loading branch information
w3b6x9 and filipecabaco committed Apr 12, 2024
1 parent 91e41fd commit 6afbc8b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions lib/realtime_web/channels/realtime_channel/presence_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,16 @@ defmodule RealtimeWeb.RealtimeChannel.PresenceHandler do
payload = Map.get(payload, "payload", %{})

case Presence.track(self(), tenant_topic, presence_key, payload) do
{:error, {:already_tracked, _, _, _}} ->
Presence.update(self(), tenant_topic, presence_key, payload)
{:ok, _} ->
:ok

_ ->
{:error, {:already_tracked, _, _, _}} ->
case Presence.update(self(), tenant_topic, presence_key, payload) do
{:ok, _} -> :ok
{:error, _} -> :error
end

{:error, _} ->
:error
end

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Realtime.MixProject do
def project do
[
app: :realtime,
version: "2.28.16",
version: "2.28.17",
elixir: "~> 1.14.0",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down

0 comments on commit 6afbc8b

Please sign in to comment.