WIP - placing calls
This commit is contained in:
@@ -56,13 +56,33 @@ export class VoiceGateway
|
||||
|
||||
// Verify JWT token
|
||||
const payload = await this.jwtService.verifyAsync(token);
|
||||
client.tenantId = payload.tenantId;
|
||||
|
||||
// Extract domain from origin header (e.g., http://tenant1.routebox.co:3001)
|
||||
// The domains table stores just the subdomain part (e.g., "tenant1")
|
||||
const origin = client.handshake.headers.origin || client.handshake.headers.referer;
|
||||
let domain = 'localhost';
|
||||
|
||||
if (origin) {
|
||||
try {
|
||||
const url = new URL(origin);
|
||||
const hostname = url.hostname; // e.g., tenant1.routebox.co or localhost
|
||||
|
||||
// Extract first part of subdomain as domain
|
||||
// tenant1.routebox.co -> tenant1
|
||||
// localhost -> localhost
|
||||
domain = hostname.split('.')[0];
|
||||
} catch (error) {
|
||||
this.logger.warn(`Failed to parse origin: ${origin}`);
|
||||
}
|
||||
}
|
||||
|
||||
client.tenantId = domain; // Store the subdomain as tenantId
|
||||
client.userId = payload.sub;
|
||||
client.tenantSlug = payload.tenantSlug;
|
||||
client.tenantSlug = domain; // Same as subdomain
|
||||
|
||||
this.connectedUsers.set(client.userId, client);
|
||||
this.logger.log(
|
||||
`Client connected: ${client.id} (User: ${client.userId}, Tenant: ${client.tenantSlug})`,
|
||||
`Client connected: ${client.id} (User: ${client.userId}, Domain: ${domain})`,
|
||||
);
|
||||
|
||||
// Send current call state if any active call
|
||||
|
||||
Reference in New Issue
Block a user