fix(controller): correctly rejected join channel if not on dev server for building

This commit is contained in:
2025-09-06 22:27:07 -05:00
parent e0be95978d
commit c78fca4316
2 changed files with 39 additions and 17 deletions

View File

@@ -13,6 +13,17 @@ import (
func registerBuildChannel(server *socketio.Server) {
// Example: When clients join "build" namespace or room
server.OnEvent("/", "subscribe:build", func(s socketio.Conn) {
host, err := os.Hostname()
if err != nil {
server.BroadcastToRoom("/", "build", "buildlogs", "Could not retrieve hostname")
return
}
if strings.Contains(host, "VMS") || strings.Contains(host, "vms") {
server.BroadcastToRoom("/", "build", "buildlogs", "You are not allowed to run the build on a production server")
return
}
s.Join("build")
s.Emit("buildlogs", "👋 Connected to build channel") // this is where all the messages are actually sent to
@@ -23,16 +34,6 @@ func registerBuildChannel(server *socketio.Server) {
fmt.Println("🔨 Build triggered:", target)
go func() {
host, err := os.Hostname()
if err != nil {
server.BroadcastToRoom("/", "build", "buildlogs", "Could not retrieve hostname")
return
}
if strings.Contains(host, "VMS") || strings.Contains(host, "vms") {
server.BroadcastToRoom("/", "build", "buildlogs", "You are not allowed to run the build on a production server")
return
}
server.BroadcastToRoom("/", "build", "buildlogs", "🔨 Starting build: Old App")
if err := runNpmV2Build(server); err != nil {