fix(controller): correctly rejected join channel if not on dev server for building
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user