Skip to content

Commit

Permalink
fix(kousa): benawad#2774 by making sure only use raise your own hand
Browse files Browse the repository at this point in the history
  • Loading branch information
amitojsingh366 committed May 16, 2021
1 parent 58c3297 commit 2e0217b
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions kousa/lib/kousa/room.ex
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ defmodule Kousa.Room do
defp set_listener(room_id, user_id, setter_id) do
# TODO: refactor this to be simpler. The list of
# creators and mods should be in the preloads of the room.
with {auth, _} <- Rooms.get_room_status(setter_id), {role, _} <- Rooms.get_room_status(user_id) do
with {auth, _} <- Rooms.get_room_status(setter_id),
{role, _} <- Rooms.get_room_status(user_id) do
if auth == :creator or (auth == :mod and role not in [:creator, :mod]) do
internal_set_listener(user_id, room_id)
end
Expand Down Expand Up @@ -327,22 +328,24 @@ defmodule Kousa.Room do
end

# only you can raise your own hand
defp set_raised_hand(room_id, user_id, _user_id) do
if Onion.RoomSession.get(room_id, :auto_speaker) do
internal_set_speaker(user_id, room_id)
else
case RoomPermissions.ask_to_speak(user_id, room_id) do
{:ok, %{isSpeaker: true}} ->
internal_set_speaker(user_id, room_id)

_ ->
Onion.RoomSession.broadcast_ws(
room_id,
%{
op: "hand_raised",
d: %{userId: user_id, roomId: room_id}
}
)
defp set_raised_hand(room_id, user_id, setter_id) do
if user_id == setter_id do
if Onion.RoomSession.get(room_id, :auto_speaker) do
internal_set_speaker(user_id, room_id)
else
case RoomPermissions.ask_to_speak(user_id, room_id) do
{:ok, %{isSpeaker: true}} ->
internal_set_speaker(user_id, room_id)

_ ->
Onion.RoomSession.broadcast_ws(
room_id,
%{
op: "hand_raised",
d: %{userId: user_id, roomId: room_id}
}
)
end
end
end
end
Expand Down

0 comments on commit 2e0217b

Please sign in to comment.