make credo happy

This commit is contained in:
Victor Martinez 2024-03-29 16:24:26 +01:00
parent d1a093d8cc
commit fd7849dfb7
7 changed files with 26 additions and 8 deletions

View file

@ -1,5 +1,5 @@
defmodule Intisync.Puid do
@doc """
@moduledoc """
Generate Probably unique identifiers
"""
use Puid

View file

@ -1,4 +1,8 @@
defmodule Intisync.SessionPubSub do
@moduledoc """
Provides function to publish/subscribe to IntiSync.PubSub topics
"""
def broadcast!(session_id, topic, event, payload) do
topic = "#{topic}:#{event}:#{session_id}"
payload = %{payload: payload, topic: topic}

View file

@ -1,7 +1,12 @@
defmodule Intisync.SessionServer do
alias Intisync.SessionPubSub
@moduledoc """
Contains the business logic of a session.
It is the source of truth of the session state.
"""
use GenServer
alias Intisync.SessionPubSub
def init(session_id) do
{:ok,
%{
@ -47,8 +52,8 @@ defmodule Intisync.SessionServer do
GenServer.call(pid, {:get_devices})
end
def is_full?(pid) do
GenServer.call(pid, {:is_full?})
def full?(pid) do
GenServer.call(pid, {:full?})
end
def handle_call({:get_id}, _from, state) do
@ -59,10 +64,10 @@ defmodule Intisync.SessionServer do
{:reply, state.devices, state}
end
def handle_call({:is_full?}, _from, state) do
is_full? = state.remote_connection_status == :connected
def handle_call({:full?}, _from, state) do
full? = state.remote_connection_status == :connected
{:reply, is_full?, state}
{:reply, full?, state}
end
def handle_call({:device_connected, index, device}, _from, state) do

View file

@ -1,4 +1,7 @@
defmodule Intisync.SessionsSupervisor do
@moduledoc """
DynamicSupervisor responsible to manage SessionServers
"""
use DynamicSupervisor
alias Intisync.SessionServer

View file

@ -1,4 +1,7 @@
defmodule IntisyncWeb.LiveViewMonitor do
@moduledoc """
Monitors LiveView processes and calls their `unmount` functions when they die
"""
use GenServer
def start_link(init_arg) do

View file

@ -1,4 +1,7 @@
defmodule IntisyncWeb.DeviceCardComponent do
@moduledoc """
Renders a device card
"""
use Phoenix.Component
import IntisyncWeb.CoreComponents

View file

@ -52,7 +52,7 @@ defmodule IntisyncWeb.RemoteLive do
{:error, :not_found}
pid ->
if SessionServer.is_full?(pid) do
if SessionServer.full?(pid) do
{:error, :unauthorized}
else
{:ok, pid}