diff --git a/build/test/prepare-plugin.sh b/build/test/prepare-plugin.sh index a014e0e..badc70d 100755 --- a/build/test/prepare-plugin.sh +++ b/build/test/prepare-plugin.sh @@ -14,11 +14,29 @@ else fi # Build -cd .. && git clone -b ${GIT_BRANCH} https://github.com/mattermost/mattermost-plugin-calls && \ -cd mattermost-plugin-calls && \ -git fetch --tags && \ -cd standalone && npm ci && cd .. && \ -cd webapp && npm ci && cd .. && \ +cd .. +if [ -d "mattermost-plugin-calls" ]; then + echo "Directory mattermost-plugin-calls already exists, using existing checkout" + cd mattermost-plugin-calls + git fetch origin + git checkout ${GIT_BRANCH} + git pull origin ${GIT_BRANCH} +else + git clone -b ${GIT_BRANCH} https://github.com/mattermost/mattermost-plugin-calls + cd mattermost-plugin-calls +fi +git fetch --tags + +# Ensure mattermost-webapp dependencies are set up +if [ ! -d "webapp/mattermost-webapp" ]; then + echo "mattermost-webapp directory not found, running install_mattermost_webapp.sh" + cd webapp && ./install_mattermost_webapp.sh && cd .. +else + echo "mattermost-webapp directory exists, skipping install_mattermost_webapp.sh" +fi + +cd standalone && npm install && cd .. && \ +cd webapp && npm install && cd .. && \ echo "replace github.com/mattermost/rtcd => ../rtcd" >> go.mod && \ go mod tidy && \ make dist MM_SERVICESETTINGS_ENABLEDEVELOPER=true diff --git a/client/client.go b/client/client.go index 04482e7..cb49bba 100644 --- a/client/client.go +++ b/client/client.go @@ -44,6 +44,13 @@ const ( WSCallLoweredHandEvent EventType = "WSCallLoweredHand" WSCallScreenOnEvent EventType = "WSCallScreenOn" WSCallScreenOffEvent EventType = "WSCallScreenOff" + + // Host control events + WSCallHostMuteEvent EventType = "WSCallHostMute" + WSCallHostScreenOffEvent EventType = "WSCallHostScreenOff" + WSCallHostLowerHandEvent EventType = "WSCallHostLowerHand" + WSCallHostRemovedEvent EventType = "WSCallHostRemoved" + WSCallUserReactedEvent EventType = "WSCallUserReacted" ) func (e EventType) IsValid() bool { @@ -58,6 +65,9 @@ func (e EventType) IsValid() bool { WSCallUnmutedEvent, WSCallMutedEvent, WSCallRaisedHandEvent, WSCallLoweredHandEvent, WSCallScreenOnEvent, WSCallScreenOffEvent, + WSCallHostMuteEvent, WSCallHostScreenOffEvent, + WSCallHostLowerHandEvent, WSCallHostRemovedEvent, + WSCallUserReactedEvent, WSCallJobStateEvent, WSJobStopEvent: return true diff --git a/client/websocket.go b/client/websocket.go index e5c60f9..9c7ddbc 100644 --- a/client/websocket.go +++ b/client/websocket.go @@ -59,6 +59,12 @@ const ( wsEventUserScreenOn = wsEvPrefix + "user_screen_on" wsEventUserScreenOff = wsEvPrefix + "user_screen_off" wsEventUserReacted = wsEvPrefix + "user_reacted" + + // Host control events + wsEventHostMute = wsEvPrefix + "host_mute" + wsEventHostScreenOff = wsEvPrefix + "host_screen_off" + wsEventHostLowerHand = wsEvPrefix + "host_lower_hand" + wsEventHostRemoved = wsEvPrefix + "host_removed" ) var ( @@ -297,6 +303,68 @@ func (c *Client) handleWSMsg(msg ws.Message) error { evType = WSCallScreenOffEvent } c.emit(evType, sessionID) + case wsEventHostMute: + channelID := ev.GetBroadcast().ChannelId + if channelID == "" { + channelID, _ = ev.GetData()["channelID"].(string) + } + if channelID != c.cfg.ChannelID { + return nil + } + sessionID, _ := ev.GetData()["session_id"].(string) + if sessionID == "" { + return fmt.Errorf("missing session_id from %s event", ev.EventType()) + } + c.emit(WSCallHostMuteEvent, sessionID) + case wsEventHostScreenOff: + channelID := ev.GetBroadcast().ChannelId + if channelID == "" { + channelID, _ = ev.GetData()["channelID"].(string) + } + if channelID != c.cfg.ChannelID { + return nil + } + sessionID, _ := ev.GetData()["session_id"].(string) + if sessionID == "" { + return fmt.Errorf("missing session_id from %s event", ev.EventType()) + } + c.emit(WSCallHostScreenOffEvent, sessionID) + case wsEventHostLowerHand: + channelID := ev.GetBroadcast().ChannelId + if channelID == "" { + channelID, _ = ev.GetData()["channelID"].(string) + } + if channelID != c.cfg.ChannelID { + return nil + } + sessionID, _ := ev.GetData()["session_id"].(string) + if sessionID == "" { + return fmt.Errorf("missing session_id from %s event", ev.EventType()) + } + c.emit(WSCallHostLowerHandEvent, sessionID) + case wsEventHostRemoved: + channelID := ev.GetBroadcast().ChannelId + if channelID == "" { + channelID, _ = ev.GetData()["channelID"].(string) + } + if channelID != c.cfg.ChannelID { + return nil + } + sessionID, _ := ev.GetData()["session_id"].(string) + if sessionID == "" { + return fmt.Errorf("missing session_id from %s event", ev.EventType()) + } + c.emit(WSCallHostRemovedEvent, sessionID) + case wsEventUserReacted: + channelID := ev.GetBroadcast().ChannelId + if channelID == "" { + channelID, _ = ev.GetData()["channelID"].(string) + } + if channelID != c.cfg.ChannelID { + return nil + } + // User reactions don't require session_id validation since they're broadcast events + c.emit(WSCallUserReactedEvent, ev.GetData()) default: } case ws.BinaryMessage: