Skip to content

Commit 3dc2795

Browse files
committed
Auth permission updates
1 parent 56ff5a8 commit 3dc2795

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

lib/ret_web/channels/hub_channel.ex

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,17 +297,23 @@ defmodule RetWeb.HubChannel do
297297
account = Guardian.Phoenix.Socket.current_resource(socket)
298298
hub = socket |> hub_for_socket
299299

300-
if (type != "photo" and type != "video") or account |> can?(spawn_camera(hub)) do
301-
broadcast!(
302-
socket,
303-
event,
304-
payload
305-
|> Map.delete("session_id")
306-
|> Map.put(:session_id, socket.assigns.session_id)
307-
|> payload_with_from(socket)
308-
)
300+
if (type == "photo" and type == "video" and
301+
account
302+
|> can?(spawn_camera(hub))
303+
|> Kernel.not()) or
304+
(type == "permission" and hub |> Ret.Hub.is_owner?(account.account_id) |> Kernel.not()) do
305+
{:noreply, socket}
309306
end
310307

308+
broadcast!(
309+
socket,
310+
event,
311+
payload
312+
|> Map.delete("session_id")
313+
|> Map.put(:session_id, socket.assigns.session_id)
314+
|> payload_with_from(socket)
315+
)
316+
311317
{:noreply, socket}
312318
end
313319

0 commit comments

Comments
 (0)